/* Linger 手机版。配色对齐桌面的深色基调（accent 取桌面设置导航同款 #7c6ff7）。 */

:root {
  --bg: #0b0f1a;
  --surface: #131a2b;
  --surface-2: #1a2338;
  --border: rgba(148, 163, 208, 0.16);
  --text: #e8ecf8;
  --muted: #8b94ad;
  --accent: #7c6ff7;
  --accent-soft: rgba(124, 111, 247, 0.14);
  --good: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* 类里写了 display 的元素（.screen/.sheet/.wait-bar/.followups…）会把 UA 的
   [hidden]{display:none} 顶掉——隐藏的全屏抽屉会看不见地罩住页面吃掉点击。 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app { height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- 顶栏 ---- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: rgba(11, 15, 26, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; min-width: 0; }
.brand-icon { width: 22px; height: 22px; border-radius: 6px; flex: none; }
/* 右侧最多同时有角标 / MCP 芯片 / 开启提醒 / 连接点 / ＋ 五样：芯片不换行，挤不下时让品牌字先让。 */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.chip { white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); }
.dot-off { background: var(--danger); }
.chip {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.chip-muted { background: rgba(139, 148, 173, 0.15); color: var(--muted); }

.icon-btn {
  border: 0; background: none; color: var(--text);
  font-size: 26px; line-height: 1; padding: 2px 10px; cursor: pointer;
}
.text-btn {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--accent); font-size: 13px; padding: 5px 12px;
  border-radius: 999px; cursor: pointer;
}
.chat-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-title {
  min-width: 0; font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 多个 Cursor 窗口各是一个项目：标题下面一行小字写清在回哪个项目。 */
.chat-sub {
  font-size: 11.5px; color: var(--muted); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- 搜索 ---- */
.search-row { padding: 8px 12px 6px; }
.search {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 12px; font: inherit; font-size: 14px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--muted); }

/* ---- 会话列表：按项目分组 ---- */
/* 组头是「项目」这一层，字号与字重要压过下面的会话标题：手机上一屏能看到好几个项目，
   组头比条目弱就分不清在哪个项目下、容易点错。sticky 在列表滚动容器里吸顶。 */
.group-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 7px;
  background: rgba(11, 15, 26, 0.94); backdrop-filter: blur(8px);
  font-size: 16px; color: var(--text); cursor: pointer; user-select: none;
}
.group-head + .group-head, .session-item + .group-head { margin-top: 6px; }
.group-head:active { opacity: 0.7; }
.group-chevron {
  flex: none; display: inline-block; width: 12px; text-align: center;
  transition: transform 0.15s ease; font-size: 11px; color: var(--muted);
}
.group-head.collapsed .group-chevron { transform: rotate(-90deg); }
/* 项目色标：与项目名一起构成可扫视的两层区分。色值只求彼此可辨，不承载语义。 */
.group-swatch { flex: none; width: 4px; height: 16px; border-radius: 2px; background: var(--muted); }
.group-swatch.swatch-0 { background: #7c6ff7; }
.group-swatch.swatch-1 { background: #34d399; }
.group-swatch.swatch-2 { background: #fbbf24; }
.group-swatch.swatch-3 { background: #f472b6; }
.group-swatch.swatch-4 { background: #38bdf8; }
.group-swatch.swatch-5 { background: #fb923c; }
.group-swatch.swatch-none { background: transparent; box-shadow: 0 0 0 1px var(--border) inset; }
.group-name {
  min-width: 0; font-weight: 700; letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.group-count { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.group-wait {
  flex: none; margin-left: auto; font-size: 11px; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 0 7px; line-height: 18px;
}
.group-busy {
  flex: none; margin-left: auto; font-size: 11px; color: var(--muted);
  background: rgba(139, 148, 173, 0.15); border-radius: 999px; padding: 0 7px; line-height: 18px;
}
.group-head.untagged .group-name { font-weight: 600; color: var(--muted); }
.session-item {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px 12px 22px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.session-item:active { background: var(--surface); }
.session-avatar {
  flex: none; width: 38px; height: 38px; border-radius: 12px;
  background: var(--surface-2); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.session-avatar.waiting { background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.session-avatar.replying { box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.5) inset; }
.session-main { flex: 1; min-width: 0; }
.session-row { display: flex; align-items: baseline; gap: 8px; }
.session-title {
  flex: 1; min-width: 0; font-weight: 500; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-item.is-waiting .session-title { font-weight: 600; }
.session-time { flex: none; font-size: 12px; color: var(--muted); }
.session-preview {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden;
}
.session-preview .txt { overflow: hidden; text-overflow: ellipsis; }
.pin-flag { color: var(--warn); font-size: 12px; flex: none; }
.wait-flag {
  flex: none; font-size: 11px; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 1px 7px;
}
.busy-flag {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--good);
  background: rgba(52, 211, 153, 0.12); border-radius: 999px; padding: 1px 7px;
}
/* 「回复中」的呼吸点：列表徽标、聊天页状态条共用。 */
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-dot.replying { background: var(--good); animation: pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .status-dot.replying, .wait-pulse, .activity-pulse.on, .step-dot.loading { animation: none; }
}

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); padding: 24px; text-align: center; }
.empty-icon { font-size: 42px; opacity: 0.5; }
.empty-sub { font-size: 12px; opacity: 0.75; }

/* ---- 聊天 ---- */
#messages { padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; display: flex; flex-direction: column; gap: 3px; }
.msg-assistant { align-self: flex-start; }
.msg-user { align-self: flex-end; }
.bubble {
  padding: 10px 13px; border-radius: var(--radius);
  word-break: break-word; overflow-wrap: anywhere; font-size: 15px;
}
.msg-assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 5px; }
.msg-user .bubble { background: linear-gradient(135deg, #6a5cf0, #8b7bff); color: #fff; border-top-right-radius: 5px; }
.msg-time { font-size: 11px; color: var(--muted); padding: 0 4px; }
.msg-user .msg-time { text-align: right; }

/* markdown 子集 */
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3 { font-size: 15px; font-weight: 700; margin: 10px 0 6px; }
.bubble h1:first-child, .bubble h2:first-child, .bubble h3:first-child { margin-top: 0; }
.bubble ul { margin: 0 0 8px; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.bubble blockquote { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--muted); margin: 0 0 8px; }
.bubble code {
  font: 12.5px/1.5 ui-monospace, Consolas, monospace;
  background: rgba(124, 111, 247, 0.12); border-radius: 5px; padding: 1px 5px;
}
.bubble pre {
  background: #0a0e18; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; overflow-x: auto; margin: 0 0 8px;
}
.bubble pre code { background: none; padding: 0; white-space: pre; }
.bubble a { color: var(--accent); }

/* ---- 活动卡片（思考过程自动同步） ---- */
.activity-card {
  margin: 0 12px 6px; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
}
.activity-card:active { background: var(--surface-2); }
.activity-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); margin-bottom: 4px;
}
.activity-pulse { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.activity-pulse.on { animation: pulse 1.4s ease-in-out infinite; }
#activity-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-expand { flex: none; color: var(--accent); font-size: 12px; }
.activity-step { display: flex; align-items: baseline; gap: 7px; font-size: 12.5px; line-height: 1.9; }
.activity-step .step-dot { flex: none; width: 6px; height: 6px; }
.activity-text {
  flex: 1; min-width: 0; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-step.think .activity-text { color: var(--muted); font-style: italic; }

/* ---- 等待条 / followups / 输入 ---- */
.wait-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 0 12px 6px; padding: 8px 12px;
  background: var(--accent-soft); border: 1px solid rgba(124, 111, 247, 0.35);
  border-radius: 10px; font-size: 13px; color: var(--accent);
}
.wait-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.wait-count, .wait-timer { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.wait-count + .wait-timer { margin-left: 8px; }
/* 没有等待、agent 正在干活时顶在输入框上方的一条：与等待条同位、互斥。 */
.replying-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 0 12px 6px; padding: 8px 12px;
  background: rgba(52, 211, 153, 0.08); border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 10px; font-size: 13px; color: var(--good);
}
#replying-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-btn {
  flex: none; border: 1px solid rgba(248, 113, 113, 0.5); background: transparent;
  color: var(--danger); font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 3px 11px; border-radius: 999px; cursor: pointer;
}
.stop-btn.confirm { background: var(--danger); color: #fff; }
.stop-btn:disabled { opacity: 0.5; }

/* 排队中的消息：agent 回来时按顺序自动发出，每条可撤回。 */
.outbox {
  margin: 0 12px 6px; padding: 8px 12px 4px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: 10px;
}
.outbox-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.outbox-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; }
.outbox-seq {
  flex: none; width: 18px; height: 18px; border-radius: 50%; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.outbox-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outbox-remove {
  flex: none; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 12.5px; padding: 2px 6px; cursor: pointer;
}
.outbox-remove:disabled { opacity: 0.4; }
.queue-flag {
  flex: none; font-size: 11px; color: var(--muted);
  background: rgba(139, 148, 173, 0.15); border-radius: 999px; padding: 1px 7px;
}

.followups { display: flex; gap: 8px; overflow-x: auto; padding: 0 12px 8px; }
.followups::-webkit-scrollbar { display: none; }
.followup {
  flex: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13px; padding: 6px 12px;
  border-radius: 999px; cursor: pointer; max-width: 70vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.followup:active { background: var(--accent-soft); }

.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  border-top: 1px solid var(--border); background: var(--bg);
}
#input {
  flex: 1; resize: none; max-height: 120px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 9px 12px; font: inherit; outline: none;
}
#input:focus { border-color: var(--accent); }
#input:disabled { opacity: 0.5; }
.send-btn {
  flex: none; border: 0; border-radius: 12px; padding: 9px 16px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.send-btn:disabled { opacity: 0.35; }

/* ---- 过程镜像抽屉 ---- */
.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg); display: flex; flex-direction: column;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  border-bottom: 1px solid var(--border);
}
.sheet-title { font-weight: 700; }
.sheet-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
/* 抽屉头下方的一行开关：镜像开关就住在这儿，关着的时候用户也得能在这里把它开回来。 */
.sheet-tools {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.sheet-tools .check { color: var(--text); font-size: 14px; }
.text-btn.off { color: var(--muted); border-style: dashed; }
.mirror-note {
  margin: 10px 12px 0; padding: 8px 12px; border-radius: 10px;
  background: rgba(251, 191, 36, 0.12); color: var(--warn); font-size: 12.5px;
}
.mirror-steps { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; gap: 10px; }
.step-rail { flex: none; width: 18px; display: flex; flex-direction: column; align-items: center; }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-top: 6px; }
.step-dot.loading { background: var(--warn); animation: pulse 1.2s infinite; }
.step-dot.completed { background: var(--good); }
.step-dot.error { background: var(--danger); }
.step-line { flex: 1; width: 1px; background: var(--border); margin-top: 3px; }
.step:last-child .step-line { display: none; }
.step-body { flex: 1; min-width: 0; padding-bottom: 2px; }
.step-kind { font-size: 12px; color: var(--muted); }
.step-detail {
  font-size: 13px; white-space: pre-wrap; word-break: break-word;
  overflow-wrap: anywhere; color: var(--text); margin-top: 2px;
}
.step-thinking .step-detail { color: var(--muted); font-style: italic; }

/* ---- 新建会话弹层 ---- */
.compose-body { padding: 12px 14px 8px; display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12px; color: var(--muted); margin-top: 6px; letter-spacing: 0.02em; }
.field-note { font-size: 12.5px; color: var(--muted); }
.field-note.error { color: var(--danger); }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick-item {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font: inherit;
}
.pick-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.pick-item .pick-swatch { flex: none; width: 4px; height: 18px; border-radius: 2px; }
.pick-main { flex: 1; min-width: 0; }
.pick-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-tag { flex: none; font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 7px; }
.pick-empty { padding: 12px; border: 1px dashed var(--border); border-radius: 10px; font-size: 13px; color: var(--muted); }
.compose-model-row { display: flex; align-items: center; gap: 10px; }
.select {
  flex: 1; min-width: 0; height: 38px; padding: 0 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 14px;
}
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
/* 模型旋钮（thinking / fast / effort / 上下文…）：一行一个，布尔是开关、枚举是下拉；
   哪个模型有哪几个由 Cursor 下发的 params 决定，这里只管排版。 */
.param-list {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.param-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; }
.param-name { font-size: 14px; color: var(--text); }
.param-select { flex: none; width: auto; min-width: 120px; height: 32px; font-size: 13px; }
.param-switch { width: 18px; height: 18px; accent-color: var(--accent); }
.compose-text {
  width: 100%; resize: vertical; min-height: 110px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; font: inherit; outline: none;
}
.compose-text:focus { border-color: var(--accent); }
.send-btn.wide { flex: 1; }

/* ---- 配对占位 / toast ---- */
.pair { align-items: center; justify-content: center; gap: 10px; padding: 32px; text-align: center; }
.pair-icon { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 6px; }
.pair h1 { font-size: 20px; }
.pair p { color: var(--muted); max-width: 420px; }
.pair b { color: var(--text); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: rgba(20, 26, 43, 0.96); border: 1px solid var(--border);
  color: var(--text); font-size: 13px;
  padding: 9px 16px; border-radius: 18px; z-index: 30;
  max-width: 92vw; text-align: center;
}
.toast-text { min-width: 0; text-align: left; line-height: 1.4; }
.toast-action {
  flex: none; border: 0; background: var(--accent); color: #fff;
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}

.banner {
  margin: 8px 12px 0; padding: 8px 12px; border-radius: 10px;
  font-size: 12.5px; text-align: center;
  background: rgba(248, 113, 113, 0.12); color: var(--danger);
}
