/* ============================================================
   CodePocket · Web 控制台样式
   深色、克制、专业工具感。桌面 3 区 / 平板 2 栏 / 手机单列。
   色板与字体严格对齐《产品与工程基线》第六节。
   ============================================================ */

/* ---------- 1. 基础 ---------- */
:root {
  --bg: #0b0e14;
  --bg-soft: #0e131d;
  --panel: #121722;
  --panel-2: #161c29;
  --panel-3: #1c2434;
  --panel-4: #222c40;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #e8edf7;
  --text-soft: #bcc6d9;
  --muted: #8b97ab;
  --faint: #5f6b80;
  --teal: #3ddc97;
  --teal-bright: #5cebb3;
  --teal-dim: rgba(61, 220, 151, .12);
  --teal-line: rgba(61, 220, 151, .3);
  --blue: #5b8cff;
  --blue-dim: rgba(91, 140, 255, .12);
  --red: #ff5c7a;
  --red-dim: rgba(255, 92, 122, .12);
  --red-line: rgba(255, 92, 122, .32);
  --amber: #f5b451;
  --amber-dim: rgba(245, 180, 81, .12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --shadow-1: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-2: 0 28px 80px rgba(0, 0, 0, .58);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --sidebar-w: 280px;
  --files-w: 320px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(760px 420px at 10% -12%, rgba(61, 220, 151, .075), transparent 62%),
    radial-gradient(860px 500px at 96% -18%, rgba(91, 140, 255, .07), transparent 60%);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
::selection { background: rgba(61, 220, 151, .26); color: #fff; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 1em; height: 1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  display: inline-block; vertical-align: -.125em;
}

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .14) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .2); }

/* 焦点环 */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid rgba(61, 220, 151, .65);
  outline-offset: 2px;
  border-radius: 6px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }

/* ---------- 2. 通用控件 ---------- */
.icon-btn {
  width: 34px; height: 34px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border-radius: var(--radius-xs);
  color: var(--muted); font-size: 15px;
  border: 1px solid transparent;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.icon-btn:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.icon-btn:active { background: rgba(255, 255, 255, .1); }
.icon-btn.sm { width: 30px; height: 30px; font-size: 14px; }
.icon-btn[disabled] { opacity: .4; }

.btn {
  height: 36px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .045); color: var(--text-soft);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease), transform .12s var(--ease);
}
.btn:hover { background: rgba(255, 255, 255, .09); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn .ic { font-size: 14px; }
.btn.primary {
  background: linear-gradient(180deg, #4ee5a5, #3ddc97);
  color: #04160e; border-color: rgba(61, 220, 151, .5);
  box-shadow: 0 4px 16px rgba(61, 220, 151, .18);
}
.btn.primary:hover { background: linear-gradient(180deg, #63efb4, #46e3a1); color: #04160e; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.btn.danger { color: #ffd9e0; border-color: var(--red-line); background: rgba(255, 92, 122, .1); }
.btn.danger:hover { background: rgba(255, 92, 122, .18); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 11.5px; border-radius: var(--radius-xs); }
.link-btn {
  color: var(--teal); font-size: 11.5px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--teal-bright); }

.chev { display: inline-flex; font-size: 13px; color: var(--faint); transition: transform .18s var(--ease); }
.chev.open { transform: rotate(180deg); }

.badge {
  height: 26px; padding: 0 9px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, .035);
  color: var(--muted); font-size: 11px; white-space: nowrap;
  flex: none;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.badge .dot.ok { background: var(--teal); box-shadow: 0 0 8px rgba(61, 220, 151, .55); }
.badge .dot.blue { background: var(--blue); box-shadow: 0 0 8px rgba(91, 140, 255, .55); }
.badge .dot.bad { background: var(--red); box-shadow: 0 0 8px rgba(255, 92, 122, .55); }
.badge .dot.warn { background: var(--amber); }

.conn-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--muted);
}
.conn-dot.ok { background: var(--teal); box-shadow: 0 0 10px rgba(61, 220, 151, .55); }
.conn-dot.blue { background: var(--blue); box-shadow: 0 0 10px rgba(91, 140, 255, .55); }
.conn-dot.bad { background: var(--red); box-shadow: 0 0 10px rgba(255, 92, 122, .5); }
.conn-dot.warn { background: var(--amber); box-shadow: 0 0 10px rgba(245, 180, 81, .5); }

/* tooltip */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%) translateY(2px);
  z-index: 90; pointer-events: none; opacity: 0;
  width: max-content; max-width: 270px;
  background: #1e2839; color: var(--text-soft);
  border: 1px solid rgba(255, 255, 255, .1); border-radius: 7px;
  padding: 5px 9px; font-size: 11px; font-weight: 400; line-height: 1.5;
  white-space: normal; text-align: left; letter-spacing: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  transition: opacity .14s var(--ease), transform .14s var(--ease);
}
[data-tip]::before {
  content: ""; position: absolute; bottom: calc(100% + 4px); left: 50%;
  transform: translateX(-50%); z-index: 91; opacity: 0; pointer-events: none;
  border: 5px solid transparent; border-top-color: #1e2839;
  transition: opacity .14s var(--ease);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tip]:hover::before, [data-tip]:focus-visible::before { opacity: 1; }
[data-tip-pos="bottom"]::after { top: calc(100% + 9px); bottom: auto; }
[data-tip-pos="bottom"]::before { top: calc(100% + 4px); bottom: auto; border-top-color: transparent; border-bottom-color: #1e2839; }
[data-tip].tip-left::after { left: auto; right: 0; transform: translateY(2px); }
[data-tip].tip-left:hover::after, [data-tip].tip-left:focus-visible::after { transform: translateY(0); }

.only-mobile { display: none !important; }

/* ---------- 3. 首屏骨架 ---------- */
.boot {
  position: fixed; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: transparent; padding: 24px;
}
.boot-wrap { width: min(760px, 100%); }
.boot-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.boot-brand img { border-radius: 10px; box-shadow: 0 6px 20px rgba(61, 220, 151, .18); }
.boot-brand strong { display: block; font-size: 18px; letter-spacing: .2px; }
.boot-brand span { display: block; font-size: 11.5px; color: var(--muted); letter-spacing: .04em; margin-top: 2px; }
.boot-skel { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
.skel { background: linear-gradient(180deg, rgba(18, 23, 34, .8), rgba(14, 19, 29, .6)); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.skel-line, .skel-block { position: relative; overflow: hidden; border-radius: 6px; background: rgba(255, 255, 255, .055); }
.skel-line { height: 12px; margin-bottom: 14px; }
.skel-block { height: 120px; margin-bottom: 16px; }
.w40 { width: 40%; } .w55 { width: 55%; } .w60 { width: 60%; } .w70 { width: 70%; }
.w75 { width: 75%; } .w80 { width: 80%; } .w90 { width: 90%; } .w95 { width: 95%; }
.skel-line::after, .skel-block::after, .skel-row::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .075) 48%, transparent 76%);
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
}
.skel-side .skel-line:first-child { height: 34px; margin-bottom: 22px; }
.boot-hint {
  display: flex; align-items: center; gap: 9px; justify-content: center;
  margin-top: 26px; color: var(--muted); font-size: 12px;
}
.boot-spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.6px solid rgba(61, 220, 151, .22); border-top-color: var(--teal);
  animation: spin .8s linear infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- 4. 布局 ---------- */
.root {
  position: relative; z-index: 1;
  height: 100%; display: flex; overflow: hidden;
}
.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 23, 34, .86), rgba(11, 15, 23, .94));
  backdrop-filter: blur(14px);
  padding-left: env(safe-area-inset-left, 0);
  z-index: 40;
}
.workspace {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  position: relative; background: transparent;
}
.files-panel {
  width: 0; flex: none; overflow: hidden;
  display: flex; flex-direction: column;
  border-left: 1px solid transparent;
  background: linear-gradient(180deg, #10151f, #0d121b);
  transition: width .22s var(--ease), border-color .22s var(--ease), opacity .18s var(--ease);
  opacity: 0; position: relative; z-index: 30;
}
.files-panel.open { width: var(--files-w); border-left-color: var(--line); opacity: 1; }
.files-panel.open .files-inner { opacity: 1; }

/* ---------- 5. 侧栏 ---------- */
.side-brand {
  height: 62px; flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
}
.brand-mark { border-radius: 9px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; flex: 1; }
.brand-text strong { font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.brand-text span { font-size: 10px; color: var(--muted); letter-spacing: .3em; margin-top: 2px; }

.project-switch { position: relative; padding: 4px 12px 2px; flex: none; }
.project-btn {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; text-align: left;
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.project-btn:hover { background: rgba(255, 255, 255, .06); border-color: var(--line-strong); }
.pico { font-size: 16px; color: var(--teal); display: inline-flex; flex: none; }
.pmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.pname { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ppath { font-size: 10px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; margin-top: 1px; }

.menu {
  position: absolute; z-index: 80;
  min-width: 190px; padding: 5px;
  background: #19212f; border: 1px solid var(--line-strong);
  border-radius: 11px; box-shadow: var(--shadow-1);
  animation: popIn .14s var(--ease);
}
.project-menu { left: 12px; right: 12px; top: calc(100% + 4px); max-height: 320px; overflow: auto; }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 9px; border-radius: 7px; text-align: left;
  font-size: 12.5px; color: var(--text-soft);
}
.menu-item:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.menu-item .ic { font-size: 14px; color: var(--muted); }
.menu-item .mi-main { flex: 1; min-width: 0; }
.menu-item .mi-sub { display: block; font-size: 10px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-item .mi-check { color: var(--teal); font-size: 13px; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.menu-danger { color: #ff9aab; }
.menu-danger:hover { background: var(--red-dim); color: #ffd2da; }

.new-session {
  margin: 10px 12px 6px; height: 38px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--radius-sm); border: 1px solid rgba(61, 220, 151, .38);
  background: linear-gradient(180deg, rgba(61, 220, 151, .16), rgba(61, 220, 151, .09));
  color: var(--teal-bright); font-size: 12.5px; font-weight: 650;
  transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.new-session:hover {
  background: linear-gradient(180deg, rgba(61, 220, 151, .24), rgba(61, 220, 151, .14));
  border-color: rgba(61, 220, 151, .55);
  box-shadow: 0 4px 18px rgba(61, 220, 151, .1);
}
.new-session .ic { font-size: 15px; }

.search-box {
  margin: 7px 12px 8px; height: 33px; flex: none;
  display: flex; align-items: center; gap: 7px;
  padding: 0 9px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid transparent; border-radius: 9px;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.search-box:focus-within { border-color: var(--teal-line); background: rgba(255, 255, 255, .055); }
.search-ico { color: var(--faint); font-size: 14px; display: inline-flex; }
.search-box input {
  flex: 1; min-width: 0; background: none; border: 0; outline: 0;
  font-size: 12px; color: var(--text); padding: 0;
}
.search-box input::placeholder { color: var(--faint); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear { color: var(--faint); font-size: 12px; display: inline-flex; padding: 3px; border-radius: 4px; }
.search-clear:hover { color: var(--text); background: rgba(255, 255, 255, .08); }

.session-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; min-height: 60px; }
.session-item {
  position: relative; width: 100%;
  padding: 9px 10px 10px; margin-bottom: 2px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-align: left;
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.session-item:hover { background: rgba(255, 255, 255, .045); }
.session-item.active { background: rgba(61, 220, 151, .075); border-color: rgba(61, 220, 151, .16); }
.session-item.active::before {
  content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 2px;
  border-radius: 2px; background: var(--teal);
}
.si-top { display: flex; align-items: baseline; gap: 8px; }
.si-title {
  flex: 1; min-width: 0; font-size: 12.8px; font-weight: 550; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-item.active .si-title { color: var(--text); }
.si-time { font-size: 10px; color: var(--faint); flex: none; }
.si-bottom { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.si-preview {
  flex: 1; min-width: 0;
  font-size: 11px; color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.si-badge { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; color: var(--teal); }
.spinner {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid rgba(61, 220, 151, .22); border-top-color: var(--teal);
  animation: spin .75s linear infinite; display: inline-block;
}
.spinner.blue { border-color: rgba(91, 140, 255, .22); border-top-color: var(--blue); }
.si-more {
  position: absolute; right: 5px; top: 5px;
  width: 24px; height: 22px; display: none; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--muted); font-size: 13px;
  background: linear-gradient(90deg, transparent, rgba(17, 22, 32, .92) 35%);
  padding-left: 10px;
}
.session-item:hover .si-more, .session-item.active .si-more { display: inline-flex; }
.si-more:hover { background: rgba(255, 255, 255, .1); color: var(--text); }
.session-empty { padding: 28px 18px; text-align: center; color: var(--faint); font-size: 11.5px; line-height: 1.8; }
.session-empty .ic { font-size: 22px; color: var(--faint); opacity: .6; display: block; margin: 0 auto 8px; }

.side-foot {
  flex: none; margin-top: auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}
.conn-card {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; text-align: left;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.conn-card:hover { background: rgba(255, 255, 255, .06); border-color: var(--line-strong); }
.conn-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.conn-label { font-size: 11.5px; font-weight: 600; color: var(--text-soft); }
.conn-sub { font-size: 10px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-actions { display: flex; gap: 6px; margin-top: 8px; }
.side-actions .icon-btn {
  flex: 1; width: auto; height: 30px; gap: 6px;
  border: 1px solid var(--line); font-size: 11.5px;
}

/* ---------- 6. 顶栏 ---------- */
.offline-bar {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 32px; padding: 5px 14px;
  background: linear-gradient(90deg, rgba(255, 92, 122, .22), rgba(255, 92, 122, .12) 60%, rgba(255, 92, 122, .2));
  border-bottom: 1px solid rgba(255, 92, 122, .28);
  color: #ffd9e0; font-size: 11.5px;
  animation: slideDown .2s var(--ease);
}
.offline-ico { display: inline-flex; font-size: 13px; color: var(--red); }
.offline-bar .link-btn { color: #ffb3c1; }

.topbar {
  flex: none; height: 60px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 14, 20, .55);
  backdrop-filter: blur(16px) saturate(1.1);
  position: relative; z-index: 20;
}
.title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.session-title {
  font-size: 14.5px; font-weight: 620; color: var(--text);
  text-align: left; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-radius: 5px; padding: 1px 4px; margin-left: -4px;
  transition: background .14s var(--ease);
}
.session-title:hover { background: rgba(255, 255, 255, .06); }
.session-sub {
  font-size: 10.5px; color: var(--faint); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 7px;
}
.session-sub .path { direction: rtl; text-align: left; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.sub-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); flex: none; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.mode-switch {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px; border: 1px solid var(--line); border-radius: 9px;
  background: rgba(255, 255, 255, .035);
}
.mode-switch button {
  height: 26px; padding: 0 9px; border-radius: 7px;
  font-size: 11px; font-weight: 550; color: var(--muted);
  transition: background .14s var(--ease), color .14s var(--ease);
}
.mode-switch button:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.mode-switch button.active { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.mode-switch button.active[data-mode="read"] { color: #a9c6ff; }
.mode-switch button.active[data-mode="full"] { color: #ff9aab; background: rgba(255, 92, 122, .14); }
.engine-badge .dot { background: var(--teal); box-shadow: 0 0 8px rgba(61, 220, 151, .5); }
.engine-badge.off .dot { background: var(--red); box-shadow: none; }
.conn-badge.offline { color: #ff9aab; border-color: var(--red-line); background: var(--red-dim); }
.mock-badge {
  color: var(--amber); border-color: rgba(245, 180, 81, .35); background: var(--amber-dim);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; font-weight: 700;
  padding: 0 7px; height: 21px;
}
.mock-badge::after {
  content: "仅演示数据"; position: absolute; top: calc(100% + 8px); right: 0; left: auto;
  transform: none; white-space: nowrap; background: #1e2839; border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 4px 8px; color: var(--muted); font-family: var(--font);
  font-size: 10.5px; letter-spacing: 0; opacity: 0; pointer-events: none; transition: opacity .14s var(--ease);
}
.mock-badge:hover::after { opacity: 1; }

/* ---------- 7. 对话区 ---------- */
.thread {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  scroll-behavior: auto; position: relative;
  background:
    radial-gradient(600px 300px at 50% 0%, rgba(91, 140, 255, .035), transparent 70%);
}
.thread-inner {
  width: 100%; max-width: 860px; margin: 0 auto;
  padding: 26px 28px 30px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 100%;
}
.thread-inner.empty { justify-content: center; padding-bottom: 8vh; }

.msg { display: flex; flex-direction: column; margin: 8px 0; }
.msg.new { animation: msgIn .16s var(--ease) both; }
.msg.mine { align-items: flex-end; }
.msg.sys { align-items: center; margin: 10px 0; }
.msg-meta {
  font-size: 10px; color: var(--faint); margin-top: 5px; padding: 0 4px;
  display: flex; align-items: center; gap: 6px;
}
.msg.mine .msg-meta { justify-content: flex-end; }

.bubble {
  max-width: 78%;
  padding: 9px 13px;
  background: linear-gradient(180deg, rgba(61, 220, 151, .17), rgba(61, 220, 151, .1));
  border: 1px solid rgba(61, 220, 151, .24);
  border-radius: 14px 14px 4px 14px;
  font-size: 13.5px; line-height: 1.65; color: #e9fff6;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.bubble.pending { opacity: .7; }
.bubble .bubble-attach { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .22); border: 1px solid rgba(255, 255, 255, .12);
  font-size: 10.5px; color: var(--text-soft); max-width: 240px;
}
.attach-chip .ic { font-size: 12px; color: var(--teal); }
.attach-chip .an { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.assistant-card {
  width: 100%;
  background: linear-gradient(180deg, rgba(22, 28, 41, .82), rgba(17, 22, 33, .86));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px 12px;
  position: relative;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .025) inset;
}
.assistant-card.error { border-color: var(--red-line); background: rgba(255, 92, 122, .05); }
.as-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; min-height: 20px;
}
.as-avatar {
  width: 18px; height: 18px; border-radius: 6px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--teal-dim); color: var(--teal); font-size: 11px;
  border: 1px solid rgba(61, 220, 151, .2);
}
.as-who { font-size: 11.5px; font-weight: 600; color: var(--teal); }
.as-engine { font-size: 10px; color: var(--faint); font-family: var(--mono); }
.as-time { font-size: 10px; color: var(--faint); margin-left: auto; }
.as-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .14s var(--ease); margin-left: 2px; }
.assistant-card:hover .as-actions, .assistant-card:focus-within .as-actions { opacity: 1; }
.as-actions .icon-btn { width: 26px; height: 26px; font-size: 13px; }
.as-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 9px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .05);
  font-size: 9.5px; color: var(--faint); font-family: var(--mono);
}
.as-foot .sp { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.as-foot .err { color: var(--red); font-family: var(--font); font-size: 10.5px; }
.stream-cursor {
  display: inline-block; width: 7px; height: 15px; margin-left: 2px;
  vertical-align: -2px; border-radius: 1.5px;
  background: var(--teal); box-shadow: 0 0 10px rgba(61, 220, 151, .5);
  animation: blink 1.05s steps(2, jump-none) infinite;
}
.assistant-waiting {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 12px; padding: 2px 0;
}
.assistant-waiting .spinner { border-color: rgba(61, 220, 151, .2); border-top-color: var(--teal); }

.thinking {
  margin: 2px 0 9px;
  border: 1px solid rgba(255, 255, 255, .055); border-radius: 9px;
  background: rgba(255, 255, 255, .022);
  overflow: hidden;
}
.thinking summary {
  list-style: none; cursor: pointer;
  padding: 6px 10px; font-size: 10.5px; color: var(--faint);
  display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary .ic { font-size: 11px; }
.thinking summary:hover { color: var(--muted); }
.thinking[open] summary { border-bottom: 1px solid rgba(255, 255, 255, .05); }
.thinking-text {
  padding: 8px 11px 9px; font-size: 11.5px; line-height: 1.7;
  color: #77839a; white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 220px; overflow-y: auto;
}

.msg-sys-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .035); border: 1px solid var(--line);
  font-size: 10.5px; color: var(--muted);
}
.msg-sys-pill .ic { font-size: 11px; }

/* 空态 */
.thread-empty {
  margin: auto; max-width: 520px; width: 100%;
  text-align: center; padding: 20px 0 40px;
  animation: fadeUp .3s var(--ease) both;
}
.empty-mark {
  width: 54px; height: 54px; margin: 0 auto 16px;
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 25%, rgba(61, 220, 151, .2), rgba(61, 220, 151, .04));
  border: 1px solid rgba(61, 220, 151, .22);
  box-shadow: 0 10px 30px rgba(61, 220, 151, .08);
}
.empty-mark img { width: 34px; height: 34px; border-radius: 8px; }
.thread-empty h2 { font-size: 19px; font-weight: 620; letter-spacing: .2px; margin-bottom: 6px; }
.thread-empty > p { font-size: 12.5px; color: var(--muted); margin-bottom: 22px; }
.empty-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.empty-chip {
  padding: 11px 13px; border-radius: 11px;
  background: rgba(255, 255, 255, .028); border: 1px solid var(--line);
  color: var(--text-soft); font-size: 12px; line-height: 1.5;
  display: flex; align-items: flex-start; gap: 9px;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .16s var(--ease);
}
.empty-chip:hover { background: rgba(61, 220, 151, .07); border-color: rgba(61, 220, 151, .28); transform: translateY(-1px); }
.empty-chip .ic { font-size: 15px; color: var(--teal); margin-top: 1px; }
.empty-chip small { display: block; font-size: 10px; color: var(--faint); margin-top: 2px; }

/* 线程内加载骨架 */
.thread-skel { width: 100%; max-width: 100%; }
.thread-skel .row { display: flex; gap: 12px; margin-bottom: 16px; }
.thread-skel .skel-row { height: 54px; border-radius: 12px; flex: 1; position: relative; overflow: hidden; background: rgba(255, 255, 255, .045); }
.thread-skel .skel-row.short { max-width: 60%; }

/* 回到底部 */
.jump-bottom {
  position: fixed; bottom: 110px; left: 50%;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  background: #1b2434; border: 1px solid var(--line-strong);
  color: var(--text-soft); font-size: 11px; box-shadow: var(--shadow-1);
  animation: fadeUp .2s var(--ease);
  z-index: 8;
}
.jump-bottom:hover { background: #232e41; color: var(--text); }
.jump-ico { display: inline-flex; font-size: 12px; color: var(--teal); }

/* ---------- 8. Markdown ---------- */
.md { font-size: 13.7px; line-height: 1.72; color: var(--text-soft); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3, .md h4 { color: var(--text); font-weight: 620; line-height: 1.4; margin: 16px 0 8px; }
.md h1 { font-size: 18px; }
.md h2 { font-size: 16px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 14.5px; }
.md h4 { font-size: 13.5px; color: var(--text-soft); }
.md ul, .md ol { margin: 0 0 10px; padding-left: 21px; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--teal); }
.md strong { color: #f1f6ff; font-weight: 620; }
.md em { color: #d3dcec; }
.md del { color: var(--faint); }
.md a { color: #82a7ff; text-decoration: underline; text-decoration-color: rgba(91, 140, 255, .35); text-underline-offset: 2px; }
.md a:hover { color: #a6c0ff; }
.md code {
  font-family: var(--mono); font-size: 11.8px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .06);
  color: #d9f7ea; padding: 1px 5px; border-radius: 5px;
  overflow-wrap: anywhere;
}
.md blockquote {
  margin: 10px 0; padding: 4px 0 4px 12px;
  border-left: 2px solid var(--teal-line);
  color: var(--muted); font-size: 12.7px;
}
.md blockquote p:last-child { margin-bottom: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.md .table-wrap { overflow-x: auto; margin: 10px 0; border: 1px solid var(--line); border-radius: 9px; }
.md .table-wrap table { margin: 0; }
.md th, .md td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md th { background: rgba(255, 255, 255, .035); color: var(--text); font-weight: 600; font-size: 11.5px; }
.md tr:last-child td { border-bottom: 0; }
.md th:last-child, .md td:last-child { border-right: 0; }
.md img { max-width: 100%; border-radius: 8px; }

.code-block {
  margin: 11px 0; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #0a0f17; overflow: hidden;
}
.code-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 11px;
  background: rgba(255, 255, 255, .03); border-bottom: 1px solid rgba(255, 255, 255, .05);
  font-size: 10px; color: var(--faint); font-family: var(--mono);
  letter-spacing: .04em;
}
.code-head .lang { text-transform: uppercase; }
.code-head .code-lines { color: rgba(255, 255, 255, .26); }
.md .task-box { color: var(--teal); font-size: 12px; margin-right: 1px; }
.code-head .code-copy {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; color: var(--faint); padding: 3px 7px; border-radius: 5px;
  font-family: var(--font);
}
.code-head .code-copy:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.code-head .code-copy.done { color: var(--teal); }
.code-block pre { margin: 0; overflow-x: auto; }
.code-block pre code {
  display: block; padding: 11px 13px; background: none; border: 0;
  font-size: 12px; line-height: 1.65; color: #cdd8ea; white-space: pre;
  border-radius: 0;
}
.md pre:not(.code-block pre) {
  background: #0a0f17; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; overflow-x: auto; margin: 11px 0;
}
.md pre code { background: none; border: 0; padding: 0; }

/* ---------- 9. 工具卡 ---------- */
.tools { display: flex; flex-direction: column; gap: 7px; margin-top: 11px; }
.tool-card {
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(9, 13, 20, .5);
  overflow: hidden;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.tool-card:hover { border-color: var(--line-strong); }
.tool-card.running { border-color: rgba(91, 140, 255, .22); }
.tool-card.error { border-color: var(--red-line); background: rgba(255, 92, 122, .045); }
.tool-head {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; text-align: left; min-height: 34px;
}
.tool-ico {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(91, 140, 255, .1); color: #87a9ff; font-size: 12.5px;
  border: 1px solid rgba(91, 140, 255, .14);
}
.tool-card.error .tool-ico { background: var(--red-dim); color: var(--red); border-color: var(--red-line); }
.tool-name { font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--text); flex: none; }
.tool-arg {
  flex: 1; min-width: 0;
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tool-arg .diff-add { color: var(--teal); }
.tool-arg .diff-del { color: var(--red); }
.tool-status { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--faint); }
.tool-status.running { color: #9dbaff; }
.tool-status.done { color: var(--teal); }
.tool-status.error { color: var(--red); }
.tool-chev { flex: none; color: var(--faint); font-size: 12px; transition: transform .18s var(--ease); }
.tool-card.open .tool-chev { transform: rotate(90deg); }
.tool-body { border-top: 1px solid rgba(255, 255, 255, .055); padding: 9px 10px 10px; }
.tool-section { margin-top: 8px; }
.tool-section:first-child { margin-top: 0; }
.tool-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 9.5px; color: var(--faint); letter-spacing: .08em; text-transform: uppercase;
  margin-bottom: 4px;
}
.tool-label .tool-copy { margin-left: auto; text-transform: none; letter-spacing: 0; font-size: 10px; display: inline-flex; align-items: center; gap: 3px; }
.tool-label .tool-copy:hover { color: var(--text); }
.tool-pre {
  margin: 0; padding: 8px 9px; border-radius: 7px;
  background: #080c12; border: 1px solid rgba(255, 255, 255, .05);
  font-family: var(--mono); font-size: 10.8px; line-height: 1.6; color: #b8c5da;
  max-height: 230px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.tool-pre.err { color: #ffb3c0; border-color: var(--red-line); background: rgba(255, 92, 122, .05); }
.tool-empty { font-size: 10.5px; color: var(--faint); font-style: italic; }

.breathe { width: 7px; height: 7px; border-radius: 50%; background: #7ea6ff; animation: breathe 1.4s ease-in-out infinite; box-shadow: 0 0 8px rgba(91, 140, 255, .6); }
.tool-status.running .spinner { width: 9px; height: 9px; }

/* ---------- 10. 输入区 ---------- */
.composer {
  flex: none; position: relative; z-index: 15;
  padding: 10px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, rgba(11, 14, 20, .72) 26%);
}
.attach-list {
  width: 100%; max-width: 860px; margin: 0 auto 8px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.attach-item {
  display: inline-flex; align-items: center; gap: 6px;
  height: 27px; padding: 0 6px 0 9px; border-radius: 7px;
  background: rgba(91, 140, 255, .09); border: 1px solid rgba(91, 140, 255, .2);
  font-size: 10.5px; color: var(--text-soft); max-width: 240px;
}
.attach-item .ic { font-size: 12px; color: var(--blue); }
.attach-item .an { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-item .rm { display: inline-flex; padding: 2px; border-radius: 4px; color: var(--faint); }
.attach-item .rm:hover { background: rgba(255, 255, 255, .1); color: var(--text); }
.attach-item.uploading { opacity: .65; }

.composer-box {
  width: 100%; max-width: 860px; margin: 0 auto;
  background: rgba(18, 23, 34, .92);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 7px 9px 6px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
}
.composer-box:focus-within {
  border-color: rgba(61, 220, 151, .38);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, .07), 0 10px 30px rgba(0, 0, 0, .25);
}
.composer-box.offline { opacity: .7; }
.input {
  width: 100%; display: block;
  min-height: 26px; max-height: 180px;
  padding: 4px 5px;
  background: none; border: 0; outline: 0; resize: none;
  color: var(--text); font-size: 13.5px; line-height: 1.55;
  overflow-y: auto;
}
.input::placeholder { color: var(--faint); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; }
.composer-left, .composer-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.composer-right { gap: 8px; }
.composer-sep { width: 1px; height: 16px; background: var(--line); margin: 0 3px; }
.mini-mode {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 3px 0 7px; border-radius: 7px;
  color: var(--muted); font-size: 11px; cursor: pointer;
}
.mini-mode:hover { background: rgba(255, 255, 255, .05); }
.mini-mode .mini-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); flex: none; }
.mini-mode[data-mode="read"] .mini-dot { background: #a9c6ff; }
.mini-mode[data-mode="edit"] .mini-dot { background: var(--teal); }
.mini-mode[data-mode="full"] .mini-dot { background: var(--red); }
.mini-mode select {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: 0; outline: 0;
  color: var(--muted); font-size: 11px; padding: 0 14px 0 0; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%);
  background-position: right 5px center, right 1px center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.mini-mode:hover select { color: var(--text); }
.composer-hint { font-size: 10px; color: var(--faint); white-space: nowrap; }
.char-count { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }
.char-count.limit { color: var(--red); }
.send-btn {
  width: 34px; height: 34px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 16px;
  background: linear-gradient(180deg, #4ee5a5, #3ddc97);
  color: #04160e; border: 1px solid rgba(61, 220, 151, .5);
  box-shadow: 0 3px 12px rgba(61, 220, 151, .18);
  transition: transform .12s var(--ease), filter .16s var(--ease), background .16s var(--ease);
}
.send-btn:hover { filter: brightness(1.06); }
.send-btn:active { transform: scale(.96); }
.send-btn:disabled { opacity: .38; filter: none; box-shadow: none; }
.send-btn.stop {
  background: rgba(255, 92, 122, .14); color: #ff97a9;
  border-color: var(--red-line); box-shadow: none;
}
.send-btn.stop:hover { background: rgba(255, 92, 122, .22); }
.send-btn.recording { background: var(--red-dim); color: var(--red); border-color: var(--red-line); animation: recPulse 1.4s ease-in-out infinite; }
.icon-btn.recording { color: var(--red); background: var(--red-dim); animation: recPulse 1.4s ease-in-out infinite; }

/* ---------- 11. 文件抽屉 ---------- */
.files-head {
  height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 0 16px; border-bottom: 1px solid var(--line);
}
.files-title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 620; color: var(--text-soft); }
.files-ico { display: inline-flex; font-size: 15px; color: var(--teal); }
.files-actions { display: flex; gap: 1px; }
.files-crumbs {
  flex: none; padding: 7px 16px 6px; font-family: var(--mono); font-size: 9.5px;
  color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-bottom: 1px solid rgba(255, 255, 255, .04);
  direction: ltr;
}
.file-tree { flex: 1; overflow: auto; padding: 7px 7px 24px; }
.tree-row {
  display: flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 8px 0 6px; border-radius: 7px;
  cursor: pointer; color: var(--text-soft); font-size: 12.3px;
  user-select: none;
}
.tree-row:hover { background: rgba(255, 255, 255, .045); }
.tree-row.active { background: rgba(61, 220, 151, .09); color: var(--text); }
.tree-row .caret { width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; color: var(--faint); font-size: 11px; transition: transform .15s var(--ease); flex: none; }
.tree-row .caret.open { transform: rotate(90deg); }
.tree-row .f-ico { display: inline-flex; font-size: 14px; color: var(--faint); flex: none; }
.tree-row.dir .f-ico { color: #e6c069; }
.tree-row.file.code .f-ico { color: #82a7ff; }
.tree-row.file.md .f-ico { color: var(--teal); }
.tree-row.file.img .f-ico { color: #d48cff; }
.tree-row.file.active .f-ico { color: var(--teal); }
.fname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-badge { font-size: 8.5px; color: var(--faint); font-family: var(--mono); flex: none; }
.tree-children { padding-left: 14px; }
.tree-loading { padding: 4px 8px 8px 28px; display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--faint); }
.tree-loading .spinner { width: 9px; height: 9px; }
.tree-empty { padding: 18px 14px; text-align: center; font-size: 11px; color: var(--faint); line-height: 1.8; }
.file-preview {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #10151f, #0c111a);
}
.preview-head {
  height: 46px; flex: none; display: flex; align-items: center; gap: 6px;
  padding: 0 8px 0 12px; border-bottom: 1px solid var(--line);
}
.preview-name {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 11px; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preview-actions { display: flex; gap: 1px; }
.preview-meta {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; font-size: 9.5px; color: var(--faint);
  font-family: var(--mono); border-bottom: 1px solid rgba(255, 255, 255, .04);
}
.preview-body { flex: 1; overflow: auto; }
.code-view { min-width: max-content; padding: 8px 0 24px; font-family: var(--mono); font-size: 11.6px; line-height: 1.68; }
.code-line { display: flex; }
.code-line .ln {
  flex: none; width: 46px; padding-right: 12px; text-align: right;
  color: rgba(255, 255, 255, .2); user-select: none;
}
.code-line .lc { white-space: pre; color: #c3cee1; padding-right: 24px; tab-size: 2; }
.preview-empty { padding: 40px 24px; text-align: center; color: var(--faint); font-size: 11.5px; line-height: 1.9; }
.preview-empty .ic { font-size: 26px; opacity: .5; display: block; margin: 0 auto 10px; }
.preview-image { padding: 16px; text-align: center; }
.preview-image img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- 12. 遮罩 / 弹窗 ---------- */
.modals { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modals > * { pointer-events: auto; }
.modal-scrim {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 7, 12, .62);
  backdrop-filter: blur(5px);
  animation: fadeIn .16s var(--ease);
}
.modal {
  position: fixed; z-index: 101;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #141a26, #10151f);
  border: 1px solid var(--line-strong); border-radius: 16px;
  box-shadow: var(--shadow-2);
  animation: popIn .18s var(--ease);
  overflow: hidden;
}
.modal.wide { width: min(660px, calc(100vw - 32px)); }
.modal-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 15px 16px 13px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 14.5px; font-weight: 620; flex: 1; }
.modal-head .modal-ico { display: inline-flex; color: var(--teal); font-size: 17px; }
.modal-head .icon-btn { margin-right: -6px; }
.modal-body { padding: 17px 20px; overflow-y: auto; }
.modal-foot {
  flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 13px 20px; border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, .12);
}
.modal-foot .spacer { flex: 1; }
.modal-text { font-size: 12.5px; color: var(--muted); line-height: 1.75; }
.modal-text strong { color: var(--text); }
.modal-text .danger-text { color: #ff9aab; }
.confirm-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--red-dim); color: var(--red); border: 1px solid var(--red-line);
  font-size: 20px; margin-bottom: 14px;
}
.confirm-head { display: flex; gap: 14px; align-items: flex-start; }

.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label {
  display: block; font-size: 11px; font-weight: 550; color: var(--muted);
  margin-bottom: 5px; letter-spacing: .02em;
}
.field .hint { font-size: 10.5px; color: var(--faint); margin-top: 5px; line-height: 1.6; }
.input-like, .field input[type="text"], .field input[type="password"], .field input[type="url"], .field select, .field textarea {
  width: 100%; height: 38px; padding: 0 11px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line-strong);
  border-radius: 9px; color: var(--text); font-size: 13px;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.field textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 64px; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal-line); background: rgba(255, 255, 255, .055); }
.field input::placeholder { color: var(--faint); }
.field select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row .field { margin-bottom: 13px; }
.field-inline { display: flex; align-items: center; gap: 10px; }
.code-input {
  width: 100%;
  font-family: var(--mono); letter-spacing: .26em; text-align: center;
  font-size: 20px !important; color: var(--teal) !important; height: 50px !important;
}
.code-input::placeholder { letter-spacing: .12em; color: var(--faint); }
.form-error {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 8px 10px; margin-bottom: 12px;
  background: var(--red-dim); border: 1px solid var(--red-line);
  border-radius: 8px; color: #ffb3c0; font-size: 11.5px; line-height: 1.55;
}
.form-error .ic { font-size: 13px; margin-top: 1px; flex: none; }
.form-note {
  display: flex; align-items: flex-start; gap: 7px;
  font-size: 10.5px; color: var(--faint); line-height: 1.7;
  padding: 9px 11px; border-radius: 8px;
  background: rgba(255, 255, 255, .025); border: 1px solid var(--line);
}
.form-note .ic { font-size: 12px; margin-top: 2px; flex: none; color: var(--blue); }
.form-note.warn { color: #e9c27c; border-color: rgba(245, 180, 81, .22); background: var(--amber-dim); }
.form-note.warn .ic { color: var(--amber); }

/* 配对弹窗 */
.pair-code-box {
  position: relative; text-align: center;
  padding: 16px 12px 17px; margin-bottom: 16px;
  background:
    radial-gradient(420px 120px at 50% 0%, rgba(61, 220, 151, .1), transparent 70%),
    #0b1018;
  border: 1px solid rgba(61, 220, 151, .18); border-radius: 13px;
}
.pair-code-label { font-size: 10px; color: var(--muted); letter-spacing: .16em; margin-bottom: 5px; }
.pair-code {
  font-family: var(--mono); font-size: 36px; font-weight: 600;
  letter-spacing: .22em; color: var(--teal); line-height: 1.25;
  text-shadow: 0 0 26px rgba(61, 220, 151, .28);
  padding-left: .22em;
  user-select: all;
}
.pair-code.dim { color: var(--faint); text-shadow: none; font-size: 24px; letter-spacing: .1em; }
.pair-expire { font-size: 10px; color: var(--faint); margin-top: 6px; }
.pair-copy {
  position: absolute; right: 10px; top: 10px;
}
.pair-code-actions { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.pair-sec { margin-bottom: 15px; }
.pair-sec:last-child { margin-bottom: 0; }
.pair-sec-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; color: var(--muted); letter-spacing: .04em; margin-bottom: 7px;
}
.pair-sec-title .ic { font-size: 13px; color: var(--faint); }
.pair-sec-title .sec-tag {
  margin-left: auto; font-size: 9px; color: var(--teal); letter-spacing: .04em;
  background: var(--teal-dim); border: 1px solid rgba(61, 220, 151, .2);
  padding: 1px 6px; border-radius: 4px;
}
.addr-list { display: flex; flex-direction: column; gap: 5px; }
.addr-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  background: rgba(255, 255, 255, .028); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; color: var(--text-soft);
  cursor: pointer; text-align: left;
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.addr-row:hover { background: rgba(255, 255, 255, .055); border-color: var(--line-strong); }
.addr-row .ic { font-size: 13px; color: var(--faint); }
.addr-row .addr { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addr-row .copy-hint { font-family: var(--font); font-size: 9.5px; color: var(--faint); }
.addr-empty { font-size: 11px; color: var(--faint); padding: 3px 2px; }
.relay-panel {
  padding: 10px 12px; border-radius: 9px;
  background: rgba(91, 140, 255, .05); border: 1px solid rgba(91, 140, 255, .16);
}
.relay-line { display: flex; align-items: center; gap: 9px; }
.relay-line + .relay-line { margin-top: 6px; }
.relay-line .rl-label { font-size: 10px; color: var(--faint); width: 46px; flex: none; }
.relay-val {
  font-family: var(--mono); font-size: 12px; color: #a9c6ff; letter-spacing: .08em;
  user-select: all; flex: 1; overflow: hidden; text-overflow: ellipsis;
}
.relay-status { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--muted); }
.relay-off { font-size: 11px; color: var(--faint); line-height: 1.7; }
.pair-note { margin-top: 13px; }

/* 设置弹窗 */
.set-section { margin-bottom: 20px; }
.set-section:last-child { margin-bottom: 0; }
.set-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .06em;
  margin-bottom: 9px;
}
.set-title .ic { font-size: 13px; color: var(--faint); }
.set-card {
  background: rgba(255, 255, 255, .025); border: 1px solid var(--line);
  border-radius: 11px; overflow: hidden;
}
.set-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-bottom: 1px solid rgba(255, 255, 255, .05);
  min-height: 46px;
}
.set-row:last-child { border-bottom: 0; }
.set-row .sr-main { flex: 1; min-width: 0; }
.set-row .sr-title { font-size: 12.5px; color: var(--text-soft); font-weight: 550; }
.set-row .sr-desc { font-size: 10.5px; color: var(--faint); margin-top: 2px; line-height: 1.55; }
.set-row .sr-side { flex: none; display: flex; align-items: center; gap: 7px; }
.engine-opt {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-bottom: 1px solid rgba(255, 255, 255, .05);
  text-align: left; font-size: 12.5px;
}
.engine-opt:last-child { border-bottom: 0; }
.engine-opt:hover { background: rgba(255, 255, 255, .03); }
.engine-opt .eo-ico {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .045); color: var(--muted); font-size: 15px;
}
.engine-opt.active .eo-ico { background: var(--teal-dim); color: var(--teal); border: 1px solid rgba(61, 220, 151, .2); }
.engine-opt .eo-main { flex: 1; min-width: 0; }
.engine-opt .eo-name { font-size: 12.5px; color: var(--text-soft); font-weight: 550; display: flex; align-items: center; gap: 7px; }
.engine-opt .eo-meta { font-size: 10px; color: var(--faint); font-family: var(--mono); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.engine-opt .eo-check { color: var(--teal); font-size: 15px; opacity: 0; }
.engine-opt.active .eo-check { opacity: 1; }
.engine-opt.unavailable { opacity: .55; }
.engine-opt.unavailable .eo-name::after { content: "不可用"; font-size: 9px; color: var(--red); border: 1px solid var(--red-line); border-radius: 4px; padding: 0 4px; }
.switch { position: relative; display: inline-flex; flex: none; width: 38px; height: 22px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .knob {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .1); border: 1px solid var(--line-strong);
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
.switch .knob::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #c4cede; transition: transform .18s var(--ease), background .18s var(--ease);
}
.switch input:checked + .knob { background: rgba(61, 220, 151, .26); border-color: var(--teal-line); }
.switch input:checked + .knob::after { transform: translateX(16px); background: var(--teal); }
.switch input:focus-visible + .knob { outline: 2px solid rgba(61, 220, 151, .65); outline-offset: 2px; }
.device-row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.device-row:last-child { border-bottom: 0; }
.dev-ico {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .04); color: var(--muted); font-size: 14px;
}
.device-row.online .dev-ico { color: var(--teal); background: var(--teal-dim); }
.dev-main { flex: 1; min-width: 0; }
.dev-name { font-size: 12px; color: var(--text-soft); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.dev-name .tag { font-size: 8.5px; color: var(--teal); border: 1px solid rgba(61, 220, 151, .25); border-radius: 4px; padding: 0 4px; font-weight: 500; }
.dev-name .tag.cur { color: var(--blue); border-color: rgba(91, 140, 255, .3); }
.dev-meta { font-size: 10px; color: var(--faint); margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.dev-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }
.dev-revoke { font-size: 10.5px; color: var(--faint); padding: 4px 6px; border-radius: 5px; }
.dev-revoke:hover { color: #ff9aab; background: var(--red-dim); }
.about-box { font-size: 10.8px; color: var(--faint); line-height: 1.85; }
.about-box strong { color: var(--text-soft); font-weight: 550; }
.about-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); padding: 3px 0; }
.about-row .k { width: 72px; color: var(--faint); flex: none; }
.about-row .v { font-family: var(--mono); font-size: 10.5px; color: var(--text-soft); }
.risk-note { margin-top: 10px; padding: 9px 11px; border: 1px solid var(--red-line); background: rgba(255, 92, 122, .05); border-radius: 8px; font-size: 10.5px; color: #e6a3ae; line-height: 1.7; }

/* 全屏入口（配对 / 中继加入 / 致命错误） */
.gate {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  padding: 22px; overflow-y: auto;
  background: var(--bg);
}
.gate::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(640px 380px at 20% -10%, rgba(61, 220, 151, .09), transparent 60%),
    radial-gradient(720px 420px at 90% -14%, rgba(91, 140, 255, .08), transparent 60%);
}
.gate-card {
  position: relative; width: min(430px, 100%);
  background: linear-gradient(180deg, #141a26, #10151f);
  border: 1px solid var(--line-strong); border-radius: 18px;
  box-shadow: var(--shadow-2); padding: 28px 26px 24px;
  animation: popIn .22s var(--ease);
}
.gate-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 22px; }
.gate-brand img { width: 46px; height: 46px; border-radius: 13px; box-shadow: 0 8px 26px rgba(61, 220, 151, .16); margin-bottom: 13px; }
.gate-brand h1 { font-size: 19px; font-weight: 650; letter-spacing: .2px; }
.gate-brand p { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.7; }
.gate-form .btn { width: 100%; height: 40px; }
.gate-form .btn.primary { margin-top: 2px; }
.gate-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.gate-server { display: flex; align-items: center; gap: 7px; justify-content: center; font-size: 10px; color: var(--faint); font-family: var(--mono); word-break: break-all; text-align: center; }
.gate-server .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); flex: none; }
.gate-error-ico {
  width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 15px;
  display: flex; align-items: center; justify-content: center;
  background: var(--red-dim); color: var(--red); font-size: 24px; border: 1px solid var(--red-line);
}
.gate-actions { display: flex; gap: 8px; margin-top: 6px; }
.gate-actions .btn { flex: 1; }
.gate-detail { margin-top: 15px; }
.gate-detail summary { font-size: 10.5px; color: var(--faint); cursor: pointer; user-select: none; }
.gate-detail pre {
  margin: 8px 0 0; padding: 9px; border-radius: 7px; max-height: 160px; overflow: auto;
  background: #080c12; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; line-height: 1.6; color: var(--muted);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.gate-skel-rows { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.gate-skel-row { height: 40px; border-radius: 9px; background: rgba(255, 255, 255, .045); position: relative; overflow: hidden; }
.gate-skel-row::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .07) 48%, transparent 76%); transform: translateX(-100%); animation: shimmer 1.4s infinite; }

/* ---------- 13. Toast ---------- */
.toasts {
  position: fixed; left: 50%; bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(440px, calc(100vw - 24px));
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 13px; border-radius: 10px;
  background: #1a2332; border: 1px solid var(--line-strong);
  color: var(--text-soft); font-size: 12px; line-height: 1.5;
  box-shadow: var(--shadow-1);
  animation: toastIn .2s var(--ease);
  word-break: break-word;
}
.toast .ic { font-size: 14px; margin-top: 1px; flex: none; color: var(--blue); }
.toast.error { border-color: var(--red-line); color: #ffc2cc; }
.toast.error .ic { color: var(--red); }
.toast.warn { border-color: rgba(245, 180, 81, .3); color: #f3d19c; }
.toast.warn .ic { color: var(--amber); }
.toast.success { border-color: rgba(61, 220, 151, .3); color: #bdf5dc; }
.toast.success .ic { color: var(--teal); }
.toast.leaving { animation: toastOut .18s var(--ease) forwards; }

/* ---------- 14. 动画 ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes breathe { 0%, 100% { opacity: .45; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes recPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 122, .35); } 50% { box-shadow: 0 0 0 5px rgba(255, 92, 122, 0); } }
@keyframes msgIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -50%) scale(.98); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 15. 响应式 ---------- */
@media (max-width: 1279px) {
  :root { --files-w: 300px; }
  .thread-inner { max-width: 800px; padding: 24px 22px 26px; }
}
@media (max-width: 1100px) {
  :root { --sidebar-w: 248px; }
  .files-panel {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(360px, 88vw) !important;
    transform: translateX(102%); opacity: 1;
    border-left: 1px solid var(--line);
    box-shadow: -18px 0 50px rgba(0, 0, 0, .42);
    transition: transform .22s var(--ease);
  }
  .files-panel.open { transform: none; }
  .files-panel .files-inner { opacity: 1; }
  .topbar { padding-left: 16px; }
  .thread-inner { max-width: 760px; }
  .engine-badge { display: none; }
}
@media (max-width: 860px) {
  .composer-hint { display: none; }
  .badge.conn-badge span:last-child { max-width: 42px; overflow: hidden; text-overflow: ellipsis; }
}

/* 手机：单列 + 左滑抽屉 */
@media (max-width: 760px) {
  :root { --sidebar-w: min(84vw, 320px); }
  .only-mobile { display: inline-flex !important; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: var(--sidebar-w);
    transform: translateX(-102%);
    transition: transform .22s var(--ease);
    box-shadow: 24px 0 60px rgba(0, 0, 0, .5);
    z-index: 90;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .root.drawer-open .sidebar { transform: none; }
  .scrim {
    position: fixed; inset: 0; z-index: 85;
    background: rgba(4, 7, 12, .55);
    backdrop-filter: blur(2px);
    animation: fadeIn .16s var(--ease);
  }
  .side-brand { height: 56px; }
  .side-brand .brand-text strong { font-size: 14.5px; }
  .session-item { min-height: 54px; padding-top: 10px; padding-bottom: 11px; }
  .si-top { padding-right: 24px; }
  .si-more { display: inline-flex; width: 34px; height: 34px; top: 2px; }
  .side-actions .icon-btn { height: 38px; }
  .conn-card { min-height: 46px; }

  .topbar { height: 54px; padding: 0 8px; gap: 6px; }
  #btn-drawer { width: 44px; height: 44px; }
  .title-wrap { gap: 0; }
  .session-title { font-size: 14px; max-width: 100%; }
  .session-sub { font-size: 9.5px; }
  .session-sub .path { max-width: 62%; }
  .mode-switch { display: none; }
  .top-actions { gap: 2px; }
  .badge { height: 24px; padding: 0 7px; font-size: 10px; }
  .conn-badge { width: auto; gap: 4px; padding: 0 6px; font-size: 9px; }
  .badge.conn-badge span:last-child { display: inline; max-width: none; overflow: visible; white-space: nowrap; }
  .mock-badge { font-size: 8px; padding: 0 4px; height: 19px; }
  #btn-files { width: 44px; height: 44px; }
  .topbar .icon-btn { width: 44px; height: 44px; }

  .thread-inner { padding: 16px 13px 18px; gap: 3px; }
  .thread-inner.empty { padding-bottom: 4vh; }
  .msg { margin: 6px 0; }
  .bubble { max-width: 88%; font-size: 13px; padding: 8px 11px; }
  .assistant-card { padding: 11px 12px 10px; border-radius: 12px; }
  .as-time { display: none; }
  .as-actions { opacity: 1; }
  .as-actions .icon-btn { width: 34px; height: 34px; font-size: 14px; }
  .md { font-size: 13.2px; }
  .md h1 { font-size: 16.5px; }
  .md h2 { font-size: 15px; }
  .tool-head { min-height: 42px; padding: 8px 9px; }
  .tool-ico { width: 24px; height: 24px; font-size: 13px; }
  .tool-arg { font-size: 10px; }
  .tool-chev { display: none; }
  .empty-chips { grid-template-columns: 1fr; }
  .thread-empty h2 { font-size: 17px; }
  .thread-empty > p { font-size: 12px; margin-bottom: 18px; }
  .empty-mark { width: 48px; height: 48px; margin-bottom: 13px; }
  .empty-mark img { width: 30px; height: 30px; }

  .composer { padding: 8px 9px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .composer-box { padding: 6px 8px 4px; border-radius: 13px; }
  .input { font-size: 16px; max-height: 132px; padding: 3px 3px 6px; } /* 16px 防 iOS 聚焦缩放 */
  .composer-left { gap: 1px; }
  .composer-left .icon-btn { width: 44px; height: 44px; font-size: 17px; }
  .composer-sep { margin: 0 1px; height: 18px; }
  .mini-mode { height: 38px; padding: 0 8px; font-size: 12px; }
  .mini-mode select { font-size: 12px; padding-right: 16px; }
  .composer-right { gap: 5px; }
  .char-count { display: none; }
  .send-btn { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }
  .attach-list { margin-bottom: 6px; }
  .jump-bottom { bottom: 8px; height: 34px; font-size: 11.5px; }

  .files-panel {
    position: fixed; inset: 0; z-index: 92;
    width: 100% !important; max-width: none;
    transform: translateX(100%);
    border-left: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: none;
  }
  .files-panel.open { transform: none; }
  .files-head { height: 56px; padding: 0 6px 0 14px; }
  .files-actions .icon-btn { width: 44px; height: 44px; }
  .preview-head { height: 52px; }
  .preview-head .icon-btn { width: 44px; height: 44px; }
  .tree-row { height: 42px; font-size: 13px; }
  .code-view { font-size: 12px; }
  .code-line .ln { width: 40px; }

  .modal {
    left: 0; top: auto; bottom: 0; transform: none;
    width: 100vw; max-height: 88vh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    animation: sheetIn .22s var(--ease);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal.wide { width: 100vw; }
  .modal-head { padding: 13px 12px 11px 17px; }
  .modal-head .icon-btn { width: 44px; height: 44px; }
  .modal-body { padding: 15px 17px; }
  .modal-foot { padding: 12px 17px; }
  .modal-foot .btn { height: 42px; min-width: 84px; }
  .field input[type="text"], .field input[type="password"], .field input[type="url"], .field select { height: 44px; font-size: 16px; }
  .code-input { height: 54px !important; font-size: 22px !important; }
  .gate { padding: 14px; }
  .gate-card { padding: 24px 19px 20px; }
  .gate-form .btn { height: 46px; }
  .pair-code { font-size: 31px; letter-spacing: .2em; }
  .pair-code-box { padding: 14px 10px 15px; }
  .socket { min-height: 0; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .offline-bar { font-size: 11px; min-height: 34px; padding: 6px 10px; gap: 6px; }
  .offline-bar .link-btn { white-space: nowrap; }
  .boot-skel { grid-template-columns: 1fr; }
  .skel-side { display: none; }
  .boot { padding: 18px; }
  .boot-brand { justify-content: center; }
  .boot-brand div { text-align: left; }
  @keyframes sheetIn { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
  @keyframes popIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}
@media (max-width: 380px) {
  .pair-code { font-size: 27px; }
  .bubble { max-width: 92%; }
  .session-title { font-size: 13.5px; }
  .modal-body { padding: 13px 14px; }
}
/* 横屏矮屏 / 平板横屏 */
@media (min-width: 761px) and (max-width: 1180px) {
  .thread-inner { padding: 20px 20px 22px; }
}
@media (max-height: 540px) and (max-width: 900px) {
  .composer { padding-top: 5px; padding-bottom: 6px; }
  .input { max-height: 84px; }
  .topbar { height: 48px; }
  .modal { max-height: 96vh; }
}

/* ---------- 16. 补充细节 ---------- */
.menu { animation: menuIn .14s var(--ease); }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }
.context-menu { position: fixed; z-index: 150; animation: menuIn .12s var(--ease); }
.icon-btn.active { color: var(--teal); background: rgba(61, 220, 151, .1); }
.engine-bar {
  background: linear-gradient(90deg, rgba(245, 180, 81, .18), rgba(245, 180, 81, .09) 60%, rgba(245, 180, 81, .16));
  border-bottom-color: rgba(245, 180, 81, .3);
  color: #f3d19c;
}
.engine-bar .ic { color: var(--amber); }
.engine-bar .link-btn { color: #f5c879; }
.set-fields { padding: 12px 13px; display: flex; flex-direction: column; gap: 11px; }
.set-fields .field { margin-bottom: 0; }
.set-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-modal .set-row select {
  height: 32px; padding: 0 9px; min-width: 84px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line-strong);
  border-radius: 7px; color: var(--text-soft); font-size: 12px; cursor: pointer;
}
.settings-modal .set-row select:focus { border-color: var(--teal-line); }
.eo-note {
  font-size: 9px; color: var(--amber); font-weight: 500;
  border: 1px solid rgba(245, 180, 81, .25); border-radius: 4px; padding: 0 5px;
}
.check-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 13px; cursor: pointer; user-select: none; }
.check-line input { width: 15px; height: 15px; accent-color: var(--teal); margin: 0; }
.tree-row.hidden-entry { opacity: .55; }
.tree-row.hidden-entry:hover { opacity: 1; }
.preview-empty .btn { margin-top: 11px; }
.confirm-head .confirm-icon { margin-bottom: 0; }
.confirm-head .modal-text { padding-top: 2px; }
.modal-text strong { color: var(--text); }
.btn:disabled { opacity: .5; }
.btn .spinner { width: 12px; height: 12px; border-width: 1.5px; border-color: rgba(255, 255, 255, .18); border-top-color: currentColor; }
.btn.primary .spinner { border-color: rgba(4, 22, 14, .22); border-top-color: #04160e; }
.thread-inner.empty .thread-skel { width: 100%; }
.jump-bottom { animation: jumpIn .18s var(--ease); }
@keyframes jumpIn { from { opacity: 0; transform: translateX(-50%) translateY(5px); } to { opacity: 1; transform: translateX(-50%); } }
.modal-body .form-error { margin-bottom: 12px; }
.form-error .ic { flex: none; }
.empty-chip span small { display: block; }
.si-more .ic { font-size: 14px; }
.offline-bar .ic { font-size: 13px; }
.set-row .sr-side .badge { height: 23px; }
.set-row .sr-side .btn.sm { height: 30px; }
.pair-sec + .pair-sec { margin-top: 0; }
.preview-body .code-view { min-width: 100%; }
.settings-modal .modal-body { max-height: min(660px, calc(100vh - 170px)); }
.files-panel .tree-empty .link-btn { margin-top: 6px; }
.file-preview .preview-empty { padding-top: 56px; }
.device-row .dev-revoke { flex: none; }
.mode-switch button[hidden] { display: none; }
.mini-mode select option { background: #171e2c; color: var(--text); }
.field .hint { color: var(--faint); }
.gate .form-error { margin-bottom: 12px; }
.gate .field:last-of-type { margin-bottom: 14px; }
.gate-form .btn { width: 100%; }
.gate-actions .btn { flex: 1; }
.icon-btn.recording { animation: recPulse 1.4s ease-in-out infinite; }
@keyframes fileIn { from { opacity: 0; } to { opacity: 1; } }
.file-preview { animation: fileIn .16s var(--ease); }

/* 动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
