/* ============ 白色主题 ============ */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --side: #fafafa;
  --panel: #ffffff;
  --text: #0f0f10;
  --text-2: #3f3f46;
  --muted: #8a8a93;
  --faint: #b3b3bb;
  --line: #ececee;
  --line-strong: #d9d9de;
  --hover: #f2f2f3;
  --soft: #f6f6f7;
  --ink: #111113;
  --link: #2f5fdd;
  --tint: #eef3ff;
  --tint-line: #d5e1ff;
  --user-bubble: #f4f4f5;
  --code-bg: #fafafa;
  --danger: #c0392b;
  --shadow-sm: 0 1px 2px rgba(16, 16, 20, .05);
  --shadow-md: 0 1px 2px rgba(16, 16, 20, .04), 0 12px 32px -12px rgba(16, 16, 20, .14);
  --shadow-lg: 0 2px 6px rgba(16, 16, 20, .05), 0 28px 70px -20px rgba(16, 16, 20, .22);
  --sans: "Inter", -apple-system, "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --side-w: 280px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #dcdce0 transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: #dfe7ff; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid #b9c8f5; outline-offset: 2px; }
textarea:focus-visible, input:focus-visible, select:focus-visible { outline: none; }

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--side-w); flex: none; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 12px 12px 10px; gap: 2px; transition: margin-left .28s var(--ease);
}
.app.collapsed .sidebar { margin-left: calc(-1 * var(--side-w)); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 14px 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15.5px; letter-spacing: .2px; }
.brand img { width: 26px; height: 26px; border-radius: 8px; box-shadow: var(--shadow-sm); }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.side-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 12px;
  background: transparent; cursor: pointer; text-align: left; transition: background .15s, box-shadow .15s, border-color .15s;
}
.side-item:hover { background: var(--hover); }
.side-item.primary {
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-weight: 500; margin-bottom: 8px;
}
.side-item.primary:hover { border-color: var(--line-strong); box-shadow: 0 2px 8px -2px rgba(16, 16, 20, .1); }
.side-item.primary svg { width: 16px; height: 16px; stroke-width: 2; }
.side-search {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; color: var(--muted);
  transition: background .15s, box-shadow .15s;
}
.side-search:hover { background: var(--hover); }
.side-search:focus-within { background: var(--panel); box-shadow: 0 0 0 1px var(--line-strong), 0 0 0 4px rgba(17, 17, 19, .04); }
.side-search input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--text); font-size: 14px; }
.side-search input::placeholder { color: var(--muted); }
.conv-group { font-size: 11.5px; font-weight: 500; letter-spacing: .6px; color: var(--faint); padding: 16px 12px 6px; position: relative; z-index: 1; }
.conv-group:first-of-type { padding-top: 14px; }
.conv-list { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 1px 6px; position: relative; }
.conv {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 12px; border-radius: 10px; cursor: pointer;
  white-space: nowrap; overflow: hidden; color: var(--text-2); font-size: 14px; position: relative; z-index: 1;
  transition: background .15s, color .2s, transform .15s var(--ease);
}
@media (hover: hover) { .conv:hover { background: var(--hover); color: var(--text); } }
.conv:active { transform: scale(.985); }
.conv.active, .conv.active:hover { background: transparent; color: var(--text); font-weight: 500; }
.conv.enter { animation: conv-in .38s var(--ease) both; }
@keyframes conv-in { from { opacity: 0; transform: translateX(-10px); } }
/* 选中项的白色底块：切换对话时滑到新位置 */
.conv-pill {
  position: absolute; left: 0; top: 0; z-index: 0; border-radius: 10px; pointer-events: none; opacity: 0;
  background: var(--panel); box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
  transition: transform .36s var(--ease), width .2s, height .2s, opacity .22s;
}
.conv-pill.on { opacity: 1; }
.conv .t { flex: 1; overflow: hidden; text-overflow: ellipsis; }
/* 重命名 / 删除：鼠标移上去时出现；当前对话一直显示（触屏上没有悬停） */
.conv .act { display: none; width: 26px; height: 26px; border-radius: 8px; }
.conv .act svg { width: 15px; height: 15px; }
.conv.active .act { display: inline-grid; }
@media (hover: hover) { .conv:hover .act { display: inline-grid; } }
.conv .act + .act { margin-left: -4px; }
.conv .del:hover { color: var(--danger); background: #fdecea; }
.conv.editing .act { display: none; }
.ren-input {
  flex: 1; min-width: 0; height: 26px; margin-left: -7px; padding: 0 6px; border: 1px solid #c9c9d1; border-radius: 7px; outline: 0;
  background: var(--panel); font-size: 14px; color: var(--text); box-shadow: 0 0 0 3px rgba(17, 17, 19, .05);
}
.conv-empty { color: var(--faint); font-size: 13px; padding: 6px 12px; }
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }
.user-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: 12px;
  background: transparent; cursor: pointer; transition: background .15s;
}
.user-btn:hover { background: var(--hover); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 600;
  background: linear-gradient(140deg, #46464f, #0c0c0e); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line);
}
.user-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.user-plan { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 0 8px; line-height: 20px; }
.gear { color: var(--faint); width: 16px; height: 16px; }

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; isolation: isolate; }
.topbar { display: flex; align-items: center; gap: 8px; height: 54px; padding: 0 14px; flex: none; position: relative; z-index: 2; }
.topbar::after {
  content: ""; position: absolute; left: 0; right: 12px; top: 100%; height: 22px; pointer-events: none;
  background: linear-gradient(#fff, rgba(255, 255, 255, 0));
}
.app.empty .topbar::after { display: none; }
.conv-title { flex: 1; text-align: center; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
#openSideBtn { visibility: hidden; }
.app.collapsed #openSideBtn { visibility: visible; }
/* 侧边栏展开时左边已经有"新建对话"，右上角这个就不重复显示 */
.app:not(.collapsed) #topNewBtn { visibility: hidden; }

.messages { flex: 1; overflow-y: auto; padding: 10px 24px 34px; }
.app.empty .messages { display: none; }

/* 首页：淡淡的点阵 + 光晕 */
.app.empty .main::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, #dadae0 1px, transparent 1.6px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 52% 46% at 50% 38%, #000 0%, transparent 78%);
  mask-image: radial-gradient(ellipse 52% 46% at 50% 38%, #000 0%, transparent 78%);
  opacity: .75;
}
/* 流动的光晕：三团颜色各自缓慢漂移、忽明忽暗，叠在一起颜色会不断变化 */
.aurora { display: none; }
.app.empty .aurora {
  display: block; position: absolute; left: 50%; top: 34%; width: min(880px, 96%); height: 420px; z-index: -1; pointer-events: none;
  transform: translate(-50%, -50%); animation: aurora-in 1.4s ease both;
}
@keyframes aurora-in { from { opacity: 0; } }
.aurora i { position: absolute; border-radius: 50%; will-change: transform, opacity; }
.aurora i:nth-child(1) {
  left: 24%; top: 10%; width: 54%; height: 78%;
  background: radial-gradient(closest-side, rgba(92, 122, 255, .19), rgba(92, 122, 255, 0));
  animation: drift-a 11s ease-in-out infinite alternate;
}
.aurora i:nth-child(2) {
  left: 46%; top: 20%; width: 52%; height: 76%;
  background: radial-gradient(closest-side, rgba(255, 156, 104, .17), rgba(255, 156, 104, 0));
  animation: drift-b 14s ease-in-out infinite alternate;
}
.aurora i:nth-child(3) {
  left: 2%; top: 24%; width: 50%; height: 72%;
  background: radial-gradient(closest-side, rgba(186, 116, 255, .14), rgba(186, 116, 255, 0));
  animation: drift-c 18s ease-in-out infinite alternate;
}
@keyframes drift-a {
  0% { transform: translate(-8%, 4%) scale(1); opacity: .85; }
  50% { transform: translate(10%, -8%) scale(1.16); opacity: 1; }
  100% { transform: translate(24%, 6%) scale(.94); opacity: .65; }
}
@keyframes drift-b {
  0% { transform: translate(8%, -6%) scale(1.06); opacity: .6; }
  50% { transform: translate(-16%, 8%) scale(.92); opacity: 1; }
  100% { transform: translate(-34%, -4%) scale(1.14); opacity: .8; }
}
@keyframes drift-c {
  0% { transform: translate(0, 6%) scale(.94); opacity: .5; }
  50% { transform: translate(20%, -10%) scale(1.12); opacity: 1; }
  100% { transform: translate(44%, 4%) scale(1); opacity: .65; }
}
.hero { display: none; }
/* 首页：问候语 + 输入框整体放在略高于正中的位置 */
.app.empty .hero { display: flex; flex: .78; align-items: flex-end; justify-content: center; padding: 0 20px 30px; }
.greeting {
  display: flex; align-items: center; gap: 16px; margin: 0; font-size: 38px; font-weight: 500; line-height: 1.25; letter-spacing: .5px; text-align: center;
  animation: rise .6s var(--ease) both;
}
.greeting span {
  background: linear-gradient(180deg, #0f0f10 20%, #6c6c76 130%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.greeting img { width: 40px; height: 40px; border-radius: 12px; box-shadow: var(--shadow-md); }
.app.empty .composer-wrap { flex: 1.22; justify-content: flex-start; }
/* 回到底部 */
.to-bottom {
  position: absolute; left: 50%; top: -52px; z-index: 3; width: 36px; height: 36px; margin-left: -18px; border-radius: 50%;
  display: grid; place-items: center; border: 1px solid var(--line); background: var(--panel); color: var(--text-2); cursor: pointer;
  box-shadow: var(--shadow-md); opacity: 0; transform: translateY(8px) scale(.9); pointer-events: none;
  transition: opacity .2s, transform .22s var(--ease), border-color .15s, color .15s;
}
.to-bottom svg { width: 17px; height: 17px; stroke-width: 2; }
.to-bottom.show { opacity: 1; transform: none; pointer-events: auto; }
.to-bottom:hover { border-color: var(--line-strong); color: var(--text); }
.app.boot.empty .composer { animation: rise .6s .06s var(--ease) both; }
/* 切换对话：内容和标题淡入 */
.messages.switching { animation: switch-in .34s var(--ease) both; }
.conv-title.switching { animation: title-in .3s var(--ease) both; }
@keyframes switch-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes title-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.composer-wrap { flex: none; display: flex; flex-direction: column; align-items: center; padding: 0 24px 14px; position: relative; }
.composer-wrap::before {
  content: ""; position: absolute; left: 0; right: 12px; top: -28px; height: 28px; pointer-events: none;
  background: linear-gradient(rgba(255, 255, 255, 0), #fff);
}
.app.empty .composer-wrap::before { display: none; }
.composer {
  width: 100%; max-width: 760px; background: var(--panel); border: 1px solid var(--line); border-radius: 26px;
  box-shadow: var(--shadow-md); padding: 14px 12px 10px 18px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .2s, box-shadow .2s;
}
.composer:hover { border-color: var(--line-strong); }
.composer:focus-within { border-color: #cfcfd6; box-shadow: var(--shadow-md), 0 0 0 4px rgba(17, 17, 19, .045); }
.composer textarea {
  border: 0; outline: 0; resize: none; background: transparent; max-height: 40vh; min-height: 28px; padding: 2px 6px 2px 0; overflow-y: hidden;
  font-size: 15.5px; line-height: 1.6;
}
.composer textarea::placeholder { color: var(--faint); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-left: -8px; }
.bar-left, .bar-right { display: flex; align-items: center; gap: 4px; }
.chip-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2); cursor: pointer; font-size: 13px;
  transition: background .15s, border-color .15s, color .15s;
}
.chip-toggle svg { width: 15px; height: 15px; }
.chip-toggle:hover { background: var(--hover); border-color: var(--line-strong); }
.chip-toggle.on { background: var(--tint); color: var(--link); border-color: var(--tint-line); }
/* ---------- 模型选择 / 额度：按钮 ---------- */
.composer { position: relative; }
.pop-anchor { position: relative; display: flex; --bar: #2f6fe4; }
.pop-anchor.lvl-warn { --bar: #e08a1e; }
.pop-anchor.lvl-danger { --bar: #d64533; }
.picker-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px 0 11px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2); font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.picker-btn .eff { color: var(--muted); }
.picker-btn svg { width: 13px; height: 13px; color: var(--muted); stroke-width: 2.2; transition: transform .2s var(--ease); }
.picker-btn:hover, .picker-btn.open { background: var(--hover); color: var(--text); }
.picker-btn.open svg { transform: rotate(180deg); }
.usage-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 9px 0 7px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background .15s, color .15s;
}
.usage-btn:hover, .usage-btn.open { background: var(--hover); color: var(--text); }
.ring { width: 18px; height: 18px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: #e4e4ea; }
.ring .arc { stroke: var(--bar); stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray .5s var(--ease); }
.ring .arc.zero { visibility: hidden; }

/* ---------- 弹出菜单 ---------- */
.menu {
  position: absolute; right: 0; bottom: calc(100% + 10px); z-index: 40; min-width: 264px; padding: 6px; border-radius: 16px;
  background: var(--panel); box-shadow: 0 0 0 1px var(--line), var(--shadow-lg); display: flex; flex-direction: column; gap: 1px;
  font-size: 14.5px; color: var(--text); transform-origin: bottom right; animation: menu-in .16s var(--ease) both;
}
.menu[hidden] { display: none; }
.menu > * { flex-shrink: 0; }
.menu.down { bottom: auto; top: calc(100% + 10px); transform-origin: top right; }
@keyframes menu-in { from { opacity: 0; transform: translateY(6px) scale(.97); } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px 0 12px; border: 0; border-radius: 10px;
  background: transparent; cursor: pointer; text-align: left; color: var(--text); transition: background .12s;
}
.menu-item:hover, .sub-wrap:hover > .menu-item, .sub-wrap.open > .menu-item { background: var(--hover); }
.menu-item .mi-label { flex: 1; white-space: nowrap; display: inline-flex; align-items: center; }
.menu-item .mi-price { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.menu-item .mi-key { width: 18px; text-align: center; font-size: 13px; color: var(--muted); }
.menu-item .mi-check { width: 18px; height: 18px; color: #2f6fe4; stroke-width: 2.2; }
.menu-item .mi-val { color: var(--muted); font-size: 13.5px; }
.menu-item .mi-chev { width: 14px; height: 14px; color: var(--muted); stroke-width: 2; }
.menu-item .mi-info { width: 14px; height: 14px; color: var(--faint); margin-left: 7px; }
.menu-item .badge { font-size: 11.5px; color: var(--muted); background: #eeeef1; border-radius: 999px; padding: 0 8px; line-height: 20px; margin-left: 9px; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 8px; }
.sub-wrap { position: relative; }
.submenu {
  display: none; position: absolute; left: calc(100% + 10px); bottom: -6px; width: 272px; padding: 6px; border-radius: 16px;
  background: var(--panel); box-shadow: 0 0 0 1px var(--line), var(--shadow-lg); animation: menu-in .14s var(--ease) both;
}
.submenu::before { content: ""; position: absolute; top: 0; bottom: 0; left: -16px; width: 16px; } /* 鼠标移过去时不断开 */
.menu.sub-left .submenu { left: auto; right: calc(100% + 10px); }
.menu.sub-left .submenu::before { left: auto; right: -16px; }
.menu.down .submenu { bottom: auto; top: -6px; }
.sub-wrap:hover > .submenu, .sub-wrap.open > .submenu { display: block; }
.sub-head { font-size: 12.5px; line-height: 1.6; color: var(--muted); padding: 8px 12px 8px; }

/* ---------- 工具菜单 ---------- */
.tool-count {
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--link); color: #fff;
  font-size: 11px; font-weight: 600; line-height: 17px; text-align: center;
}
.tool-count[hidden] { display: none; }
.menu.left { right: auto; left: 0; transform-origin: bottom left; }
.menu.left.down { transform-origin: top left; }
.tools-menu { width: 326px; }
.tool-row { height: auto; padding: 9px 10px 9px 12px; gap: 12px; }
.tool-row > svg { width: 18px; height: 18px; color: var(--text-2); }
.tr-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tr-text b { font-weight: 500; font-size: 14px; }
.tr-text small { font-size: 12px; line-height: 1.45; color: var(--muted); white-space: normal; }
.switch { position: relative; flex: none; width: 34px; height: 20px; border-radius: 99px; background: #dcdce2; transition: background .2s; }
.switch::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .22s var(--ease);
}
.tool-row[aria-checked="true"] .switch { background: #2f6fe4; }
.tool-row[aria-checked="true"] .switch::after { transform: translateX(14px); }

/* ---------- 额度面板 ---------- */
.usage-pop { width: 336px; padding: 16px 18px 14px; gap: 0; font-size: 14px; overflow-y: auto; }
.up-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.up-head a { color: var(--text); text-decoration: none; }
.up-head a:hover { text-decoration: underline; }
.up-row { margin-bottom: 15px; }
.up-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.up-label { font-weight: 500; }
.up-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.up-meta b { font-weight: 500; margin-left: 9px; }
.bar { height: 5px; border-radius: 99px; background: #e9e9ee; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--bar); transition: width .5s var(--ease); }
.up-sub { margin-top: 8px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.up-sub b { font-weight: 600; color: var(--text); }
.up-sec { font-size: 11.5px; letter-spacing: .5px; color: var(--faint); margin: 0 0 10px; }
.up-row.small { margin-bottom: 12px; }
.up-row.small .up-label { font-weight: 400; font-size: 13.5px; color: var(--text-2); }
.up-row.small .bar { height: 4px; }
.up-row.small .bar i { background: #b9c0cf; }
.up-empty { color: var(--faint); font-size: 13px; margin-bottom: 14px; }
.up-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.up-foot button, .up-cal button {
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2); border-radius: 8px; padding: 2px 10px; font-size: 12.5px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.up-foot button:hover, .up-cal button:hover { background: var(--hover); border-color: var(--line-strong); }
.up-cal { display: grid; grid-template-columns: 1fr 104px; gap: 8px 10px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.up-cal[hidden] { display: none; }
.up-cal input {
  height: 32px; width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 0 9px; outline: 0; background: var(--panel);
  font-size: 13.5px; font-variant-numeric: tabular-nums; transition: border-color .15s, box-shadow .15s;
}
.up-cal input:focus { border-color: #c9c9d1; box-shadow: 0 0 0 3px rgba(17, 17, 19, .05); }
.up-cal .acts { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.up-cal .acts .go { background: var(--ink); border-color: var(--ink); color: #fff; padding: 3px 14px; }
.up-cal .acts .go:hover { background: #000; }
.up-note { margin-top: 10px; font-size: 11.5px; line-height: 1.55; color: var(--faint); }
.send-btn {
  width: 36px; height: 36px; margin-left: 4px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--ink); color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 4px 12px -4px rgba(0, 0, 0, .35);
  transition: transform .15s var(--ease), background .15s, box-shadow .15s;
}
.send-btn svg { stroke-width: 2.1; }
.send-btn:hover { transform: translateY(-1px); background: #000; }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { background: #ededf0; color: #b9b9c1; box-shadow: none; cursor: default; transform: none; }
.send-btn .i-stop { display: none; fill: currentColor; stroke: none; }
.app.busy .send-btn .i-send { display: none; }
.app.busy .send-btn .i-stop { display: block; }
.app.busy .send-btn { background: var(--ink); color: #fff; cursor: pointer; }

.suggest { display: none; }
.app.empty .suggest {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 760px; margin-top: 20px;
  animation: rise .6s .14s var(--ease) both;
}
.suggest button {
  border: 1px solid var(--line); background: rgba(255, 255, 255, .8); border-radius: 999px; padding: 7px 15px; font-size: 13.5px;
  color: var(--text-2); cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .18s var(--ease), border-color .15s, color .15s, box-shadow .15s;
}
.suggest button:hover { transform: translateY(-1px); border-color: var(--line-strong); color: var(--text); box-shadow: 0 6px 16px -8px rgba(16, 16, 20, .22); }

.hint { font-size: 12px; color: var(--faint); margin-top: 10px; text-align: center; }
.app.empty .hint { visibility: hidden; }
.hint.err, .app.empty .hint.err { visibility: visible; color: var(--danger); font-size: 13px; }

.attach-row { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.attach-row:empty { display: none; }
.att {
  position: relative; display: flex; align-items: center; gap: 9px; max-width: 220px; height: 54px; padding: 0 12px 0 7px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--soft); font-size: 13px; color: var(--text-2);
}
.att img { width: 40px; height: 40px; object-fit: cover; border-radius: 9px; }
.att .ico { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); color: var(--text-2); font-size: 10.5px; font-weight: 700; letter-spacing: .4px; }
.att .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .x {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: var(--ink); color: #fff; cursor: pointer; display: grid; place-items: center; padding: 0; font-size: 13px; line-height: 1;
  opacity: 0; transition: opacity .15s;
}
.att:hover .x { opacity: 1; }

/* ---------- 消息 ---------- */
.msg { max-width: 760px; margin: 0 auto 26px; }
.msg.enter { animation: rise .32s var(--ease) both; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  background: var(--user-bubble); padding: 10px 16px; border-radius: 20px 20px 6px 20px; max-width: 82%;
  white-space: pre-wrap; word-break: break-word; line-height: 1.65;
}
.user-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 8px; }
.user-files img { max-width: 220px; max-height: 180px; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow-sm); cursor: zoom-in; }
.msg.assistant .md { word-break: break-word; line-height: 1.8; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .7em 0; }
.md h1, .md h2, .md h3, .md h4 { font-weight: 600; line-height: 1.4; margin: 1.5em 0 .5em; letter-spacing: .1px; }
.md h1 { font-size: 1.4em; } .md h2 { font-size: 1.22em; } .md h3 { font-size: 1.08em; } .md h4 { font-size: 1em; }
.md ul, .md ol { padding-left: 1.4em; margin: .6em 0; }
.md li { margin: .3em 0; }
.md li::marker { color: var(--muted); }
.md strong { font-weight: 600; }
.md a { color: var(--link); text-decoration: none; border-bottom: 1px solid rgba(47, 95, 221, .3); transition: border-color .15s; }
.md a:hover { border-bottom-color: var(--link); }
.md blockquote { margin: .9em 0; padding: .1em 0 .1em 1.1em; border-left: 2px solid var(--line-strong); color: var(--text-2); }
.md code { font-family: var(--mono); font-size: .88em; background: #f2f2f4; color: #2b2b31; padding: .14em .42em; border-radius: 6px; }
/* 代码块：标题栏（语言名 + 复制）+ 代码 */
.md .code-block { margin: 1em 0; border: 1px solid var(--line); border-radius: 14px; background: var(--code-bg); overflow: hidden; }
.code-head {
  display: flex; align-items: center; justify-content: space-between; height: 36px; padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--line); background: #f4f4f6; font-size: 12px; color: var(--muted);
}
.code-lang { font-family: var(--mono); letter-spacing: .2px; }
.code-head .copy {
  border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 4px 10px; border-radius: 8px; cursor: pointer;
  transition: background .15s, color .15s;
}
.code-head .copy:hover { background: #e9e9ed; color: var(--text); }
.md pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.md pre code { background: none; padding: 0; font-size: 13.5px; line-height: 1.65; color: #1c1c21; }
/* 语法高亮配色 */
.hljs-comment, .hljs-quote { color: #7d8590; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-doctag, .hljs-meta .hljs-keyword, .hljs-template-tag { color: #cf222e; }
.hljs-string, .hljs-regexp, .hljs-meta .hljs-string { color: #0a3069; }
.hljs-number, .hljs-literal, .hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-selector-class, .hljs-selector-id, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-operator { color: #0550ae; }
.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-section { color: #8250df; }
.hljs-built_in, .hljs-type, .hljs-symbol, .hljs-bullet { color: #953800; }
.hljs-name, .hljs-tag { color: #116329; }
.hljs-meta { color: #6e7781; }
.hljs-addition { color: #116329; background: #dafbe1; }
.hljs-deletion { color: #82071e; background: #ffebe9; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

/* 表格：放不下时整张表横向滚动，不把列挤成一个字一行 */
.md .table-wrap { margin: 1em 0; overflow-x: auto; }
.md table { border-collapse: separate; border-spacing: 0; font-size: 14px; word-break: normal; overflow-wrap: normal; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 9px 14px; text-align: left; min-width: 6.5em; }
.md th { font-weight: 600; color: var(--text-2); background: var(--soft); border-bottom-color: var(--line-strong); white-space: nowrap; }
.md th:first-child { border-radius: 10px 0 0 0; } .md th:last-child { border-radius: 0 10px 0 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.md img { max-width: 100%; border-radius: 12px; }

/* ---------- 过程显示：思考 + 工具调用（Claude Code 的样子） ----------
   .steps = 一组连续的步骤。多步：一行概括 + 可展开的列表；只有一步（.single）：一行灰字。 */
.steps { margin: 0 0 14px; font-size: 14px; }
.md + .steps, .notice + .steps { margin-top: 14px; }
.steps-head, .step-row {
  display: flex; align-items: center; gap: 6px; max-width: 100%; border: 0; background: transparent; padding: 0;
  font-size: 14px; line-height: 1.5; color: #73737c; text-align: left; cursor: pointer; transition: color .15s;
}
.steps-head:hover, .step-row:hover { color: var(--text); }
.steps .chev { width: 14px; height: 14px; flex: none; stroke-width: 2; opacity: .75; transition: transform .2s var(--ease); }
.steps.open > .steps-head .chev, .step.open > .step-row .chev { transform: rotate(90deg); }
.steps-head { padding: 2px 0; }
.sh-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps.single > .steps-head { display: none; }
.steps:not(.open):not(.single) > .steps-list { display: none; }

.steps-list { margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; animation: steps-in .22s var(--ease) both; }
@keyframes steps-in { from { opacity: 0; transform: translateY(-4px); } }
.step + .step { border-top: 1px solid var(--line); }
.step-row { width: 100%; padding: 9px 14px; }
.st-label { flex: none; }
.st-hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #9a9aa3; }
.st-hint.mono { font-family: var(--mono); font-size: 12.5px; }
.st-status { flex: none; font-size: 13px; color: #9a9aa3; }
.step.err .st-status { color: var(--danger); }
.step.running .st-label, .steps.running .sh-text {
  background: linear-gradient(90deg, #a2a2ab 0%, #18181b 50%, #a2a2ab 100%); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.8s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.step-body { display: none; padding: 0 14px 12px; }
.step.open > .step-body { display: block; }
.sb-label { font-size: 11.5px; letter-spacing: .4px; color: var(--faint); margin: 10px 0 4px; }
.sb-label:first-child { margin-top: 0; }
.step-body pre {
  margin: 0; padding: 9px 11px; max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; background: var(--code-bg);
  font: 12.5px/1.6 var(--mono); color: #1c1c21; white-space: pre-wrap; word-break: break-word;
}
.sb-text { max-height: 320px; overflow-y: auto; font-size: 13.5px; line-height: 1.7; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.step-links { display: flex; flex-direction: column; gap: 5px; }
.step-links a { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 13px; color: var(--text-2); text-decoration: none; }
.step-links a:hover { color: var(--link); }
.step-links a small { flex: none; color: var(--faint); font-size: 12px; }

/* 只有一步：不要边框，就是一行灰字，展开的内容缩进显示 */
.steps.single > .steps-list { margin-top: 0; border: 0; border-radius: 0; background: none; overflow: visible; animation: none; }
.steps.single .step-row { width: auto; padding: 2px 0; }
.steps.single .step-body { margin: 6px 0 2px 2px; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.tool-files { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 10px; }
.tool-files[hidden] { display: none; }
.gen-img { display: block; max-width: min(100%, 560px); border-radius: 12px; }
.gen-img img { display: block; max-width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow-sm); background: var(--soft); }
/* 第一次加载、还不知道尺寸时：先占一块 3:2 的位置，带流光 */
.gen-img.loading { width: 560px; aspect-ratio: 3 / 2; background: linear-gradient(100deg, #f1f1f3 30%, #fafafb 50%, #f1f1f3 70%) 0 0 / 200% 100%; animation: shimmer 1.6s linear infinite; }
.gen-img.loading img { opacity: 0; }
.file-link {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--text-2); font-size: 13px; text-decoration: none; transition: border-color .15s, color .15s, background .15s;
}
.file-link:hover { border-color: var(--line-strong); color: var(--text); background: var(--soft); }
.file-link svg { width: 15px; height: 15px; color: var(--muted); }
.file-link small { color: var(--faint); }
.notice { font-size: 13px; color: var(--text-2); background: var(--soft); border-radius: 10px; padding: 7px 12px; margin: 8px 0; }
.error-box {
  border: 1px solid #f3d3ce; color: var(--danger); background: #fdf3f1; border-radius: 14px; padding: 11px 15px; font-size: 14px; margin-top: 8px;
}
.sources { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.sources a {
  font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 11px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
}
.sources a:hover { color: var(--text); border-color: var(--line-strong); background: var(--soft); }
.msg-foot { display: flex; align-items: center; gap: 8px; margin: 10px 0 0 -7px; font-size: 12px; color: var(--faint); transition: color .2s; }
.msg:hover .msg-foot { color: var(--muted); }
.msg-foot button {
  border: 0; background: transparent; color: inherit; cursor: pointer; padding: 3px 7px; border-radius: 8px; font-size: 12px;
  transition: background .15s, color .15s;
}
.msg-foot button:hover { background: var(--hover); color: var(--text); }

/* 流式输出时的光标 */
.md.cursor:empty::after, .md.cursor > :last-child::after {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 5px; border-radius: 50%;
  background: var(--ink); vertical-align: baseline; animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; transform: scale(.75); } }
.waiting { display: inline-flex; gap: 5px; padding: 10px 0; }
.waiting i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); opacity: .18; animation: dot 1.2s infinite; }
.waiting i:nth-child(2) { animation-delay: .18s; } .waiting i:nth-child(3) { animation-delay: .36s; }
@keyframes dot { 30% { opacity: .9; transform: translateY(-3px); } }

/* ---------- 弹窗 / 拖放 ---------- */
dialog {
  border: 0; border-radius: 22px; padding: 0; background: var(--panel); color: var(--text); width: min(520px, 92vw);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-lg);
}
dialog[open] { animation: pop .26s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog::backdrop { background: rgba(20, 20, 24, .26); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dlg { padding: 26px 28px 24px; display: flex; flex-direction: column; gap: 16px; }
.dlg h2 { margin: 0 0 2px; font-size: 19px; font-weight: 600; }
.dlg label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.dlg input, .dlg textarea {
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; background: var(--panel); color: var(--text); outline: 0;
  resize: vertical; font-weight: 400; font-size: 14.5px; transition: border-color .15s, box-shadow .15s;
}
.dlg input::placeholder, .dlg textarea::placeholder { color: var(--faint); }
.dlg input:focus, .dlg textarea:focus { border-color: #c9c9d1; box-shadow: 0 0 0 4px rgba(17, 17, 19, .05); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.btn {
  border: 1px solid var(--line); background: var(--panel); padding: 7px 18px; border-radius: 11px; cursor: pointer; font-size: 14px;
  transition: background .15s, border-color .15s, transform .15s var(--ease);
}
.btn:hover { background: var(--hover); border-color: var(--line-strong); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .35); }
.btn.primary:hover { background: #000; transform: translateY(-1px); }
.drop-mask {
  position: fixed; inset: 14px; display: none; place-items: center; border-radius: 22px; z-index: 50; pointer-events: none;
  background: rgba(255, 255, 255, .82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1.5px dashed #a9a9b3; font-size: 18px; font-weight: 500; color: var(--text-2);
}
.drop-mask.show { display: grid; }
.scrim { display: none; }

/* ---------- 手机 ---------- */
@media (max-width: 760px) {
  /* 手机上侧边栏浮在内容上面：用 transform 平移（GPU 合成，不用每帧重新排版），遮罩用透明度淡入淡出，
     不用全屏模糊（backdrop-filter 在手机上很吃性能，侧边栏一动就掉帧） */
  .sidebar {
    position: fixed; z-index: 30; inset: 0 auto 0 0; box-shadow: var(--shadow-lg);
    margin-left: 0 !important; transition: transform .3s var(--ease), box-shadow .3s; will-change: transform;
  }
  .app.collapsed .sidebar { transform: translate3d(calc(-100% - 24px), 0, 0); box-shadow: none; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 20; background: rgba(20, 20, 24, .3);
    opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); will-change: opacity;
  }
  .app:not(.collapsed) .scrim { opacity: 1; pointer-events: auto; }
  #openSideBtn, .app:not(.collapsed) #topNewBtn { visibility: visible; }
  .greeting { font-size: 28px; gap: 12px; }
  .greeting img { width: 32px; height: 32px; border-radius: 10px; }
  .messages { padding: 8px 16px 28px; }
  .composer-wrap { padding: 0 12px 10px; }
  .composer { border-radius: 22px; padding: 12px 10px 8px 16px; }
  .chip-toggle { padding: 0 9px; }
  .chip-toggle span { display: none; }
  .bubble { max-width: 90%; }
  /* 手机上菜单贴着输入框上沿，子菜单改成原地展开 */
  .pop-anchor { position: static; }
  .menu { right: 6px; bottom: calc(100% + 8px); max-width: calc(100vw - 36px); overflow-y: auto; }
  .menu.down { top: calc(100% + 8px); }
  .usage-pop { width: min(336px, calc(100vw - 36px)); }
  .menu.left { left: 6px; right: auto; }
  .tools-menu { width: min(326px, calc(100vw - 36px)); }
  .usage-btn span { display: none; }
  .submenu, .menu.sub-left .submenu { position: static; width: auto; box-shadow: none; padding: 0 0 4px 10px; animation: none; }
  .submenu::before { display: none; }
  .sub-wrap:hover > .submenu { display: none; }
  .sub-wrap.open > .submenu { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .aurora i { animation: none !important; }
}

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(246, 246, 247, .72); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.login-mask[hidden] { display: none; }
.login-card {
  width: min(380px, 100%); background: var(--panel); border-radius: 22px;
  box-shadow: 0 0 0 1px var(--line), var(--shadow-lg); animation: pop .26s var(--ease) both;
}
.login-card h2 { display: flex; align-items: center; gap: 10px; }
.login-card h2 img { width: 26px; height: 26px; }
.login-card .btn.primary { padding: 10px 18px; font-size: 15px; }
.login-card .btn:disabled { opacity: .6; cursor: default; transform: none; }
.login-err { min-height: 18px; margin: -6px 0 -4px; font-size: 13px; color: var(--danger); }
.login-note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.dlg-actions .logout-btn { margin-right: auto; color: var(--danger); }
.login-quick { display: flex; flex-direction: column; gap: 10px; }
.login-quick[hidden] { display: none; }
.login-quick-title { font-size: 13px; font-weight: 500; color: var(--text-2); }
.login-quick-list { display: flex; flex-direction: column; gap: 8px; }
.quick-user { display: flex; align-items: center; gap: 10px; padding: 9px 14px; text-align: left; font-size: 15px; }
.quick-user .avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 600;
}
.quick-user:disabled { opacity: .6; cursor: default; }
.login-or { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 触屏：去掉点击灰块、双击放大，输入框不小于 16px（iOS 聚焦时不自动放大） ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
* { -webkit-tap-highlight-color: transparent; }
@media (hover: none) {
  .conv:active { background: var(--hover); }
  input, textarea, select, .composer textarea, .dlg input, .dlg textarea, .side-search input, .ren-input { font-size: 16px; }
}
