/* frapp — ChatGPT-style design tokens */
:root {
  color-scheme: light dark;
  --font: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --sidebar: #f9f9f9;
  --surface-2: #f4f4f4;
  --hover: #ececec;
  --active: #e3e3e3;
  --text: #0d0d0d;
  --text-2: #5d5d5d;
  --text-3: #8f8f8f;
  --border: rgba(0, 0, 0, .1);
  --border-light: rgba(0, 0, 0, .06);
  --code-bg: #f9f9f9;
  --code-head: #f3f3f3;
  --inline-code: #ececec;
  --accent: #0d0d0d;
  --accent-text: #ffffff;
  --accent-hover: #2f2f2f;
  --send-disabled: #d7d7d7;
  --send-disabled-text: #f4f4f4;
  --composer-bg: #ffffff;
  --composer-shadow: 0 4px 12px rgba(0, 0, 0, .05), 0 0 1px rgba(0, 0, 0, .6);
  --elevated-shadow: 0 8px 28px rgba(0, 0, 0, .08), 0 0 1px rgba(0, 0, 0, .4);
  --green: #10a37f;
  --red: #e02e2a;
  --amber: #c27c0e;
  --yellow: #e2a400;
  --diff-add-bg: #e6ffec;
  --diff-add: #116329;
  --diff-del-bg: #ffebe9;
  --diff-del: #82071e;
  --shade: rgba(0, 0, 0, .4);
  --focus: #0d0d0d;
  --blue: #3a83f7;
  --rail-tick: #d2d3d3;
  --slider-track: #e8e8e8;
  --slider-dot: #a3a3a3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --sidebar: #181818;
    --surface-2: #303030;
    --hover: #262626;
    --active: #2f2f2f;
    --text: #ececec;
    --text-2: #b4b4b4;
    --text-3: #8f8f8f;
    --border: rgba(255, 255, 255, .12);
    --border-light: rgba(255, 255, 255, .07);
    --code-bg: #171717;
    --code-head: #2a2a2a;
    --inline-code: #424242;
    --accent: #ffffff;
    --accent-text: #0d0d0d;
    --accent-hover: #d9d9d9;
    --send-disabled: #676767;
    --send-disabled-text: #2f2f2f;
    --composer-bg: #303030;
    --composer-shadow: none;
    --elevated-shadow: 0 8px 28px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .08);
    --diff-add-bg: rgba(16, 163, 127, .16);
    --diff-add: #7ee2b8;
    --diff-del-bg: rgba(248, 81, 73, .16);
    --diff-del: #ffa198;
    --amber: #f0b44c;
    --yellow: #f5c542;
    --shade: rgba(0, 0, 0, .6);
    --focus: #ececec;
    --blue: #4d93f8;
    --rail-tick: #4a4a4a;
    --slider-track: #3a3a3a;
    --slider-dot: #7a7a7a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, input, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.hidden { display: none !important; }
.muted { color: var(--text-3); font-size: 14px; }
.error { min-height: 1.4em; margin: 12px 0 0; color: var(--red); font-size: 14px; }

svg {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* Buttons */
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 18px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-text);
  font-size: 15px; font-weight: 500;
  transition: background .15s ease, opacity .15s ease;
}
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.primary:disabled { opacity: .35; }
.primary svg { width: 18px; height: 18px; stroke-width: 2; }
.secondary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 8px 18px;
  border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--text);
  font-size: 15px; font-weight: 500;
  transition: background .15s ease;
}
.secondary:hover:not(:disabled) { background: var(--surface-2); }
.secondary:disabled { opacity: .45; }
.wide { width: 100%; }
.ghost-pill {
  min-height: 34px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--text);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.ghost-pill:hover:not(:disabled) { background: var(--surface-2); }
.ghost-pill:disabled { opacity: .45; }
.controller-pill { min-width: 76px; text-align: center; }
.controller-pill.daemon { color: var(--text-2); }
.controller-pill.terminal { color: var(--amber); }
.controller-pill:disabled { opacity: 1; cursor: default; }
.icon-button {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2);
}
.icon-button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-button:disabled { opacity: .35; }
.mobile-only { display: none; }

/* Login */
.login-shell { display: grid; min-height: 100dvh; place-items: center; padding: 24px; background: var(--bg); }
.login-card { display: flex; flex-direction: column; align-items: center; width: min(100%, 340px); text-align: center; }
.frapp-logo { fill: currentColor; stroke: none; }
.brand-mark { display: grid; place-items: center; margin-bottom: 24px; color: var(--text); }
.brand-mark svg { width: 44px; height: 44px; }
.login-card h1 { margin: 0 0 10px; font-size: 32px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.login-sub { margin: 0; color: var(--text-2); font-size: 15px; line-height: 1.6; }
.login-card form { display: grid; gap: 14px; width: 100%; margin-top: 28px; }
.field { position: relative; }
.field input {
  width: 100%; height: 52px; padding: 18px 20px 6px;
  border: 1px solid var(--border); border-radius: 999px;
  outline: none; background: var(--bg); color: var(--text); font-size: 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.field label {
  position: absolute; top: 50%; left: 21px;
  color: var(--text-3); font-size: 16px; pointer-events: none;
  transform: translateY(-50%); transform-origin: left center;
  transition: transform .15s ease, color .15s ease, top .15s ease;
}
.field input:focus + label, .field input:not(:placeholder-shown) + label {
  top: 14px; transform: translateY(-50%) scale(.75);
}
.field input:focus + label { color: var(--green); }
.login-card .primary { height: 52px; font-size: 16px; }
.login-foot { margin: 36px 0 0; color: var(--text-3); font-size: 12px; }
.link-button { margin-top: 10px; padding: 4px 8px; border: 0; background: transparent; color: var(--text-3); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover:not(:disabled) { color: var(--text-2); }
.link-button:disabled { opacity: .45; }

/* Layout */
.app-shell { display: flex; width: 100%; height: 100dvh; overflow: hidden; background: var(--bg); }
/* 分屏 (panes.js): this view and up to three iframe panes side by side; the dock bar spans them. */
.stage { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.pane-row { display: flex; flex: 1; min-height: 0; }
.pane-row > .main { flex: 1 1 0; }
.pane-row { position: relative; }
.pane { position: relative; display: flex; flex: 1 1 0; min-width: 0; overflow: hidden; background: var(--bg); }
/* A pane's page fades in once loaded; panes grow in and shrink away (flex-grow), except while a divider is dragged. */
.pane-frame { flex: 1; width: 100%; height: 100%; border: 0; background: var(--bg); opacity: 0; transition: opacity .2s ease; }
.pane.ready .pane-frame { opacity: 1; }
.app-shell.split .pane-row > :is(.main, .pane) { transition: flex-grow .24s cubic-bezier(.2, .7, .3, 1); }
.pane-row.resizing > :is(.main, .pane) { transition: none; }
.pane-row.resizing .pane-frame { pointer-events: none; }
/* The focused pane: a grey bar along its top, drawn over whatever it shows (an iframe would cover a border). */
.app-shell.split .pane-row > .pane-focused::after {
  position: absolute; top: 0; right: 0; left: 0; z-index: 5; height: 2px; background: var(--text-3); content: ''; pointer-events: none;
}
/* Divider between two panes: a hairline with a wider grab area; drag to resize, double-click to even out. */
.pane-gutter { position: relative; z-index: 6; flex: none; width: 1px; background: var(--border-light); cursor: col-resize; }
.pane-gutter::before { position: absolute; top: 0; bottom: 0; left: -4px; width: 9px; content: ''; }
.pane-gutter:hover, .pane-row.resizing .pane-gutter { background: var(--text-3); }
/* While a sidebar row is dragged: a layer over the panes (iframes would take the drag) showing where it lands. */
.pane-drop { position: absolute; inset: 0; z-index: 60; }
.pane-drop-hint {
  position: absolute; top: 8px; bottom: 8px; display: grid; place-items: center; padding: 12px;
  border: 2px dashed var(--text-3); border-radius: 14px; background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--text-2); font-size: 14px; transition: left .12s ease, width .12s ease; pointer-events: none;
}
.pane-drop-hint:empty { display: none; }
.dock-bar { display: none; }
/* The shared strip widens symmetrically with each pane: one composer's width for one pane, the full width at four. */
.app-shell.split .dock-bar { display: flex; flex: none; flex-direction: column; padding: 0 16px calc(4px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-light); background: var(--bg); --dock-span: calc(768px + (100% - 768px) * (var(--panes) - 1) / 3); }
.app-shell.split .dock-bar .dock-tabs { width: min(100%, var(--dock-span)); justify-content: safe center; } /* tabs stay centred as it widens */
.app-shell.split .dock-bar .dock-panel { width: min(100%, max(900px, var(--dock-span))); margin-top: 8px; }
.app-shell.split .stage:has(.dock-bar .dock-panel.maximized:not(.hidden)) .pane-row { display: none; }
.app-shell.split .stage:has(.dock-bar .dock-panel.maximized:not(.hidden)) .dock-bar { flex: 1; }
.app-shell.split .dock-bar .dock-panel.maximized { flex: 1; height: auto; }
.app-shell.split .dock-bar:not(:has(.dock-tabs:not(.hidden))):not(:has(.dock-panel:not(.hidden))) { display: none; }
/* Inside a pane: no sidebar, no tabs; a × in the top bar closes the pane. */
.pane-only { display: none !important; }
.pane-mode .pane-only { display: grid !important; }
.pane-mode .sidebar, .pane-mode .sidebar-shade, .pane-mode #open-sidebar, .pane-mode #dock-tabs, .pane-mode #dock-panel,
.pane-mode #dock-windows, .pane-mode .dock-bar { display: none !important; }

/* Sidebar */
.sidebar {
  display: flex; flex: 0 0 260px; flex-direction: column;
  min-width: 0; height: 100%;
  background: var(--sidebar);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; flex: none; height: 56px; padding: 0 8px 0 14px; }
.brand-inline { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 15px; font-weight: 600; }
.brand-symbol { display: grid; place-items: center; width: 28px; height: 28px; color: var(--text); }
.brand-symbol svg { width: 26px; height: 26px; }
.project-block { display: grid; gap: 2px; flex: none; padding: 2px 8px 8px; }
.nav-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 38px; padding: 0 8px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--text);
  text-align: left; font-size: 14px;
}
.nav-row:hover { background: var(--hover); }
.nav-row svg { width: 19px; height: 19px; }
.sidebar-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex: none; padding: 14px 16px 6px;
  color: var(--text-3); font-size: 13px;
}
#loaded-count { font-size: 12px; white-space: nowrap; }
.sidebar-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--active) transparent;
  /* Keep the scrollbar's space reserved so rows don't jump sideways when a fold makes the list short. */
  scrollbar-gutter: stable;
}
.mounted-list, .thread-list { padding: 0 8px 6px; }
.mounted-list:empty::after { display: block; padding: 8px 16px 12px; color: var(--text-3); content: '暂无活跃会话'; font-size: 12px; }
.history-section .sidebar-label { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--border-light); }
.thread-list > .muted { padding: 8px; }
.thread {
  display: block; width: 100%; margin: 0; padding: 7px 8px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--text);
  text-align: left; line-height: 1.35;
}
.thread { position: relative; overflow: hidden; }
.thread-main, .thread small { position: relative; }
/* A faint quarter of the agent's logo in the bottom-right corner marks Claude vs Codex sessions. */
.thread .agent-watermark {
  position: absolute; right: -7.5px; bottom: -7px; width: 30px; height: 30px;
  fill: currentColor; stroke: none; opacity: .09; pointer-events: none;
}
.thread .agent-watermark.claude { color: #d97757; opacity: .2; filter: saturate(.55); }
.thread .agent-watermark.grok, .thread .agent-watermark.opencode { opacity: .11; }
.thread .agent-watermark.note { fill: none; stroke: currentColor; stroke-width: 1.6; opacity: .16; transform: rotate(-18deg); }
.thread.active .agent-watermark, .thread:hover .agent-watermark { opacity: .14; }
.thread:hover .agent-watermark.note { opacity: .24; }
.thread.active .agent-watermark.claude, .thread:hover .agent-watermark.claude { opacity: .28; }
.thread:hover { background: var(--hover); }
.thread.active { background: var(--active); }
.thread-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.thread.editing { background: var(--active); cursor: text; }
.thread-title-input {
  flex: 1; min-width: 0; margin: -2px -4px; padding: 1px 4px;
  border: 1px solid var(--text-3); border-radius: 6px; outline: none;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px; line-height: 1.35;
}
.thread-title { flex: 1; min-width: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.thread small { display: block; margin-top: 2px; overflow: hidden; color: var(--text-3); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.thread-status { display: none; flex: none; width: 8px; height: 8px; margin-right: -4px; border-radius: 50%; background: var(--yellow); }
.thread-status.running { display: inline-block; box-shadow: 0 0 0 0 color-mix(in srgb, var(--yellow) 60%, transparent); animation: running-blink 1.2s ease-in-out infinite; }
.thread-status.running.waiting { background: var(--amber); }
@keyframes running-blink {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--yellow) 55%, transparent); }
  50% { opacity: .3; box-shadow: 0 0 0 3px transparent; }
}
/* Pulled right into the row padding; the dot's -4px keeps both centred on the same line. */
.thread-done { display: inline-grid; flex: none; place-items: center; width: 16px; height: 16px; margin-right: -8px; color: var(--green); }
.thread-done svg { width: 16px; height: 16px; stroke-width: 2; }
@media (prefers-reduced-motion: reduce) { .thread-status.running { animation: none; } }
.mounted-row { display: flex; align-items: center; min-width: 0; }
.mounted-row .thread { flex: 1; min-width: 0; }
.thread-row { display: flex; align-items: center; min-width: 0; }
.thread-row .thread { flex: 1; min-width: 0; }
.rename-current { display: grid; place-items: center; flex: none; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; }
.rename-current svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rename-current:hover { background: var(--hover); color: var(--text); }
.unmount-button { display: grid; place-items: center; flex: none; width: 28px; height: 28px; margin-right: 4px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); font-size: 20px; line-height: 1; }
.unmount-button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.unmount-button:disabled { opacity: .4; }
.history-edge { min-height: 48px; padding: 13px 14px 18px; color: var(--text-3); font-size: 12px; text-align: center; }
.history-edge.loading { color: var(--text-2); }
/* Usage: Codex and Claude side by side (click for reset times) */
.usage { flex: none; margin: 4px 8px 2px; padding: 8px 8px 9px; border-radius: 10px; cursor: pointer; }
.usage:hover { background: var(--hover); }
.usage:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.usage-meters { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.usage-meters.claude-meters { grid-template-columns: repeat(3, 1fr); gap: 10px; }
.weekly-limit-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; color: var(--text-3); font-size: 11px; }
.weekly-limit-heading strong { color: var(--text-2); font-size: 11px; font-weight: 500; white-space: nowrap; }
.weekly-limit-track { height: 3px; margin-top: 5px; overflow: hidden; border-radius: 99px; background: var(--active); }
.weekly-limit-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--text-2); transition: width .2s ease; }
.weekly-limit.low .weekly-limit-track > span { background: var(--amber); }
.weekly-limit.empty .weekly-limit-track > span { background: var(--red); }
.usage-details { display: none; margin-top: 8px; }
.usage[aria-expanded="true"] .usage-details { display: grid; gap: 3px; }
.usage-details small { color: var(--text-3); font-size: 11px; line-height: 1.4; }
.usage-details .usage-more { margin: 6px 0 2px; }
/* Reset times right under the three Claude meters, same columns. */
.usage-resets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: -4px; }
.usage-resets small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-row kbd { margin-left: auto; padding: 1px 6px; border: 1px solid var(--border); border-radius: 6px; color: var(--text-3); font: 11px/1.5 var(--mono, monospace); }
.search-row span { flex: 1; }

/* Search dialog (ChatGPT-style) */
.search-dialog { width: min(640px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 80px)); margin: min(12vh, 110px) auto auto; padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 18px; background: var(--bg); color: var(--text); box-shadow: 0 24px 64px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.06); }
.search-dialog[open] { display: flex; flex-direction: column; animation: search-in .14s ease-out; }
.search-dialog::backdrop { background: rgba(0, 0, 0, .28); }
@keyframes search-in { from { opacity: 0; transform: translateY(-6px) scale(.99); } }
.search-head { display: flex; flex: none; align-items: center; gap: 10px; padding: 8px 8px 8px 18px; border-bottom: 1px solid var(--border-light); }
.search-head > svg { width: 20px; height: 20px; color: var(--text-3); }
.search-head input { flex: 1; min-width: 0; height: 44px; border: 0; outline: none; background: transparent; color: var(--text); font-size: 16px; }
.search-head input::-webkit-search-cancel-button { display: none; }
.search-results { flex: 1; min-height: 120px; overflow-y: auto; padding: 6px 8px 10px; overscroll-behavior: contain; }
.search-group { margin: 12px 10px 4px; color: var(--text-3); font-size: 12px; font-weight: 500; }
.search-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 12px; border: 0; border-radius: 12px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.search-item.active { background: var(--hover); }
.search-item > svg { flex: none; width: 18px; height: 18px; color: var(--text-2); }
.search-item-main { flex: 1; min-width: 0; }
.search-item-title { display: block; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.search-item-title mark { border-radius: 3px; background: color-mix(in srgb, var(--blue) 22%, transparent); color: inherit; }
.search-item-main small { display: block; overflow: hidden; margin-top: 1px; color: var(--text-3); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.search-item-date { flex: none; color: var(--text-3); font-size: 12px; }
.search-empty { margin: 36px 0; color: var(--text-3); font-size: 14px; text-align: center; }
.app-download { display: flex; flex: none; align-items: center; gap: 10px; margin: 0 8px 8px; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
.app-download:hover { background: var(--hover); }
.app-download svg { width: 19px; height: 19px; color: var(--text-2); }
.app-download span { min-width: 0; }
.app-download strong { display: block; font-size: 13px; font-weight: 500; }
.app-download small { display: block; overflow: hidden; color: var(--text-3); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.guest-usage { display: grid; gap: 2px; margin-top: 6px; }
.guest-usage .guest-usage-title { color: var(--text-2); }
.account-line { flex: none; margin: 0 18px 2px; overflow: hidden; color: var(--text-3); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.account-line { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.account-line:hover { color: var(--text-2); }
.account-line .account-switch { flex: none; width: 12px; height: 12px; }
.legacy-hint { flex: none; margin: 0 14px 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--amber); font-size: 11.5px; line-height: 1.4; text-align: left; }
.legacy-hint:hover { background: var(--hover); }
/* Guest accounts (src/accounts.mjs) have no notes or favorites. */
body.guest #open-favorites, body.guest #open-notes, body.guest .project-add-note,
body.guest #selection-bar [data-act="favorite"], body.guest #selection-bar [data-act="note"] { display: none; }

/* Main */
.main { position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 8px; flex: none; height: 56px; padding: 0 12px 0 20px; }
.title-wrap { display: flex; flex: 1; align-items: baseline; gap: 10px; min-width: 0; }
.title-heading { display: flex; align-items: center; min-width: 0; }
.rename-current { width: 27px; height: 27px; margin-left: 4px; }
.title-wrap h2 { flex: 0 1 auto; min-width: 0; margin: 0; overflow: hidden; font-size: 17px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.title-wrap span { flex: 0 1 auto; min-width: 0; overflow: hidden; color: var(--text-3); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.rename-dialog { width: min(360px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--border); border-radius: 18px; background: var(--bg); color: var(--text); box-shadow: var(--elevated-shadow); }
.rename-dialog::backdrop { background: var(--shade); }
.rename-dialog form { display: grid; gap: 14px; }
.rename-dialog strong { font-size: 17px; }
.rename-dialog input { width: 100%; box-sizing: border-box; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; }
.rename-dialog .error { min-height: 0; margin: -6px 0 0; }
.rename-actions { display: flex; justify-content: flex-end; gap: 8px; }
.rename-actions button { min-height: 36px; padding: 7px 14px; border: 0; border-radius: 9px; background: var(--surface-2); color: var(--text); cursor: pointer; }
.rename-actions .primary { background: var(--text); color: var(--bg); }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.preview-dialog { width: min(1100px, calc(100vw - 20px)); height: min(850px, calc(100dvh - 20px)); max-width: none; max-height: none; padding: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--bg); color: var(--text); box-shadow: var(--elevated-shadow); }
.preview-dialog[open] { display: flex; flex-direction: column; }
.preview-dialog::backdrop { background: var(--shade); }
.preview-head { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 7px 12px 7px 18px; border-bottom: 1px solid var(--border); }
.preview-head strong { flex: none; font-size: 15px; }
.preview-head form { display: flex; align-items: center; gap: 8px; min-width: 0; margin-left: auto; }
.preview-head label { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.preview-head input { width: 84px; height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; }
.preview-head form button { height: 34px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--text); color: var(--bg); cursor: pointer; }
.preview-status { margin: 0; padding: 9px 18px; color: var(--text-3); font-size: 13px; }
.preview-frame { width: 100%; min-height: 0; flex: 1; border: 0; background: white; }
@media (max-width: 600px) { .preview-dialog { width: 100vw; height: 100dvh; border: 0; border-radius: 0; } .preview-head { gap: 6px; padding: 6px 8px; } .preview-head label { display: none; } .preview-head input { width: 68px; } .preview-head strong { font-size: 13px; } }
.connection { display: flex; align-items: center; gap: 6px; padding: 0 8px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.dot.online { background: var(--green); }
.dot.offline { background: var(--red); }
.session-metrics { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(800px, calc(100% - 32px)); min-height: 30px; margin: 0 auto; padding: 3px 0 7px; color: var(--text-3); font-size: 12px; }
.session-metrics span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-metrics #run-status.running { color: var(--green); }
.session-metrics #context-status { display: none; }
.notice {
  flex: none; width: min(768px, calc(100% - 32px)); margin: 4px auto 8px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 14px; line-height: 1.5;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  width: min(100%, 640px); margin: auto; padding: 24px 24px 12vh; text-align: center;
}
.empty-state h2 { margin: 0; font-size: 28px; font-weight: 500; letter-spacing: -.01em; line-height: 1.3; }
.empty-state p { margin: 12px 0 28px; color: var(--text-2); font-size: 15px; line-height: 1.6; }

/* Conversation */
.conversation {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--active) transparent;
}
.messages { width: min(100%, 800px); min-height: 100%; margin: 0 auto; padding: 24px 16px 40px; }
.messages > .muted { text-align: center; }
.prompt-rail { position: absolute; z-index: 5; top: 50%; left: 0; width: 44px; transform: translateY(-50%); touch-action: none; }
.prompt-rail button { position: absolute; left: 2px; width: 7px; height: 2px; padding: 0; border: 0; border-radius: 1px; background: var(--rail-tick); cursor: pointer; transition: width .2s cubic-bezier(.2,.8,.2,1), background-color .15s ease; }
.prompt-rail button.active { background: var(--text); }
.prompt-rail button:focus-visible { outline: none; }
.prompt-preview { position: absolute; z-index: 6; left: 44px; width: min(380px, calc(100vw - 64px)); padding: 12px 14px 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg); box-shadow: var(--elevated-shadow); pointer-events: none; transition: top .16s cubic-bezier(.2,.8,.2,1); animation: preview-in .14s ease-out; }
.prompt-preview strong, .prompt-preview span { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.prompt-preview strong { color: var(--text); font-size: 14px; font-weight: 600; line-height: 1.45; -webkit-line-clamp: 2; }
.prompt-preview span { max-height: 4.8em; margin-top: 6px; color: var(--text-3); font-size: 13.5px; line-height: 1.6; -webkit-line-clamp: 4; }
.prompt-preview span.clipped { -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
@keyframes preview-in { from { opacity: 0; transform: translateX(-4px); } }
.execution-group { margin: 2px 0 18px; border: 1px solid var(--border-light); border-radius: 14px; background: var(--surface-2); }
.execution-summary { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 42px; padding: 9px 12px; border: 0; background: transparent; color: var(--text-2); font-size: 13px; text-align: left; }
.execution-summary svg { flex: none; width: 16px; height: 16px; }
.execution-summary strong { flex: 1; color: var(--text); font-weight: 500; }
.execution-progress { display: none; width: 3ch; overflow: hidden; white-space: nowrap; color: var(--text-2); }
.execution-group.running .execution-progress { display: inline-block; animation: execution-dots 1.2s steps(3, end) infinite; }
.execution-failed { color: var(--red); font-size: 12px; }
.execution-detail { padding: 0 12px 12px; }
.execution-detail .tool-row { margin-top: 8px; border-top: 1px solid var(--border-light); }
.execution-detail .tool-row summary { display: flex; align-items: flex-start; gap: 8px; padding: 10px 0 3px; color: var(--text-2); cursor: pointer; list-style: none; font-size: 13px; }
.execution-detail .tool-row summary::-webkit-details-marker { display: none; }
.execution-detail .tool-row summary > svg { flex: none; width: 15px; height: 15px; margin-top: 2px; }
.execution-detail .tool-row summary > .chev { margin-left: auto; transition: transform .15s ease; }
.execution-detail .tool-row[open] summary > .chev { transform: rotate(90deg); }
.tool-row-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-row-path { display: block; overflow: hidden; color: var(--text-3); font: 12px/1.5 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.execution-detail pre { max-height: 45vh; margin: 6px 0 0; padding: 8px; overflow: auto; border-radius: 8px; background: var(--code-bg); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.execution-detail .detail-loading { margin: 4px 0; color: var(--text-3); font-size: 12px; }
.message { position: relative; width: 100%; margin: 0 0 20px; }
.message .role { display: none; }
.message .body { color: var(--text); font-size: 16px; line-height: 1.75; overflow-wrap: anywhere; }

.message.user {
  width: fit-content; max-width: min(80%, 560px); margin: 8px 0 24px auto;
  padding: 10px 18px; border-radius: 22px; background: var(--surface-2);
}
.message.user .body { line-height: 1.6; white-space: pre-wrap; }
.message.user.question-reply { max-width: min(92%, 650px); border: 1px solid var(--border); background: var(--bg); }
.question-reply-title { margin-bottom: 8px; color: var(--text-3); font-size: 12px; font-weight: 600; }
.question-reply-row + .question-reply-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light); }
.question-reply-question { margin-bottom: 5px; color: var(--text-2); font-size: 13px; }
.question-reply-answer { color: var(--text); font-size: 15px; font-weight: 500; }
.async-question-card { max-width: 650px; padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.async-question-card > strong { display: block; margin-bottom: 10px; font-size: 15px; }
.async-question-group + .async-question-group { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-light); }
.async-question-group p { margin: 0 0 10px; font-size: 14px; line-height: 1.5; }
.async-question-group textarea { display: block; width: 100%; min-height: 54px; margin-top: 10px; padding: 9px 11px; resize: vertical; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; line-height: 1.5; }
.async-question-card > button { margin-top: 12px; }
.async-question-done { color: var(--text-3); font-size: 13px; }

/* Markdown (assistant) */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 24px 0 8px; font-weight: 600; line-height: 1.4; }
.md h1 { font-size: 1.5em; }
.md h2 { font-size: 1.3em; }
.md h3 { font-size: 1.15em; }
.md h4, .md h5, .md h6 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 1.6em; }
.md li { margin: 4px 0; padding-left: .2em; }
.md li::marker { color: var(--text-2); }
.md blockquote { margin: 0 0 12px; padding: 0 0 0 14px; border-left: 3px solid var(--border); color: var(--text-2); }
.md hr { height: 1px; margin: 24px 0; border: 0; background: var(--border); }
.md a { color: var(--text); text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 3px; }
.md strong { font-weight: 600; }
.md code {
  padding: .15em .35em; border-radius: 6px;
  background: var(--inline-code); font: 500 .875em var(--mono);
}
.md .path { font-size: .85em; overflow-wrap: anywhere; white-space: normal; }
.md .local-reference { color: var(--text-2); }
.md .table-wrap { margin: 0 0 12px; overflow-x: auto; }
.md table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.md th, .md td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.md th { font-weight: 600; border-bottom-color: var(--text-3); }
.code-block { margin: 12px 0; overflow: hidden; border: 1px solid var(--border-light); border-radius: 12px; background: var(--code-bg); }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 36px; padding: 0 8px 0 14px;
  background: var(--code-head); color: var(--text-2); font-size: 12px;
}
.copy-button {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2); font-size: 12px;
}
.copy-button:hover { background: var(--hover); color: var(--text); }
.copy-button svg { width: 15px; height: 15px; }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; font: 13px/1.6 var(--mono); white-space: pre; tab-size: 4; }
.code-block pre code { padding: 0; background: none; font: inherit; }

/* Plan */
.message.plan { padding: 14px 18px; border: 1px solid var(--border); border-radius: 16px; }
.message.plan .role { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.message.plan .body { font-size: 15px; }

/* Tool activity — collapsible rows like ChatGPT "Thought for …" */
.message.tool { margin: 0 0 6px; }
.message.tool + .message.agent, .message.tool + .message.user { margin-top: 18px; }
.message.agent + .message.tool { margin-top: -6px; }
.tool-toggle > summary {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 3px 0; color: var(--text-2); cursor: pointer; list-style: none;
  font-size: 14px; line-height: 1.5;
}
.tool-toggle > summary::-webkit-details-marker { display: none; }
.tool-toggle > summary:hover { color: var(--text); }
.tool-toggle > summary > svg { width: 16px; height: 16px; }
.tool-toggle > summary > .chev { width: 14px; height: 14px; color: var(--text-3); transition: transform .15s ease; }
.tool-toggle[open] > summary > .chev { transform: rotate(90deg); }
.message.tool .body { min-width: 0; overflow: hidden; color: inherit; font-size: 14px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.message.tool .item-status { flex: none; color: var(--text-3); font-size: 12px; }
.message.tool .item-status.done { display: none; }
.message.tool .item-status.failed { color: var(--red); }
.message.tool .item-status.running { color: var(--text-3); }
.message.tool.running .body {
  background: linear-gradient(90deg, var(--text-3) 0%, var(--text-3) 35%, var(--text) 50%, var(--text-3) 65%, var(--text-3) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 2s linear infinite;
}
.message.tool .tool-detail {
  max-height: 360px; margin: 6px 0 10px; padding: 12px 14px; overflow: auto;
  border: 1px solid var(--border-light); border-radius: 12px;
  background: var(--code-bg); color: var(--text);
  font: 12.5px/1.6 var(--mono); overflow-wrap: anywhere; white-space: pre-wrap;
}
.message.reasoning .tool-detail {
  padding: 2px 0 2px 16px; border: 0; border-left: 2px solid var(--border); border-radius: 0;
  background: transparent; color: var(--text-2); font: 14px/1.7 var(--font);
}

/* Diffs */
.diff .ctx { display: block; }
.diff .add { display: block; background: var(--diff-add-bg); color: var(--diff-add); }
.diff .del { display: block; background: var(--diff-del-bg); color: var(--diff-del); }
.diff .hunk { display: block; color: var(--text-3); }
.diff .meta { display: block; color: var(--text); font-weight: 600; }
.diff-box { width: min(100%, 800px); margin: 0 auto; padding: 0 16px 24px; }
.diff-box details { overflow: hidden; border: 1px solid var(--border); border-radius: 16px; }
.diff-box summary {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  color: var(--text); cursor: pointer; list-style: none; font-size: 14px; font-weight: 500;
}
.diff-box summary::-webkit-details-marker { display: none; }
.diff-box summary:hover { background: var(--surface-2); }
.diff-box summary svg { width: 18px; height: 18px; color: var(--text-2); }
.diff-box summary .chevron { margin-left: auto; transition: transform .15s ease; }
.diff-box details[open] summary .chevron { transform: rotate(180deg); }
.diff-stats { font: 500 12.5px var(--mono); }
.diff-stats .plus { color: var(--green); }
.diff-stats .minus { margin-left: 6px; color: var(--red); }
.diff-box pre {
  max-height: 420px; margin: 0; padding: 12px 0; overflow: auto;
  border-top: 1px solid var(--border-light); background: var(--code-bg);
  font: 12.5px/1.6 var(--mono); white-space: pre;
}
.diff-box pre > span { padding: 0 16px; }
.message.tool .tool-detail.diff { padding: 10px 0; white-space: pre; }
.message.tool .tool-detail.diff > span { padding: 0 14px; }

.history-note {
  display: block; margin: 0 auto 24px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); color: var(--text-2); font-size: 13px;
}
.history-note:hover { background: var(--surface-2); color: var(--text); }
.turn-footer { display: flex; align-items: center; gap: 2px; margin: -12px 0 28px -6px; color: var(--text-3); font-size: 12px; }
.turn-action { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; }
.turn-action:hover { background: var(--hover); color: var(--text); }
.turn-action svg { width: 17px; height: 17px; }
.turn-footer-meta { margin-left: 8px; overflow: hidden; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }

/* Approvals */
.approvals { flex: none; max-height: 45dvh; padding: 4px 16px 8px; overflow: auto; }
.approval {
  width: min(100%, 768px); margin: 0 auto 8px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--bg); box-shadow: var(--elevated-shadow);
}
.approval h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.approval h3::before { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); content: ""; animation: pulse 1.6s ease-in-out infinite; }
.approval p { margin: 4px 0 10px; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.approval pre {
  max-height: 140px; margin: 0; padding: 10px 14px; overflow: auto;
  border: 1px solid var(--border-light); border-radius: 12px; background: var(--code-bg);
  font: 12.5px/1.6 var(--mono); overflow-wrap: anywhere; white-space: pre-wrap;
}
.approval-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.approval-actions button { min-height: 36px; padding: 6px 16px; font-size: 14px; }

/* Composer */
.composer-wrap { position: relative; flex: none; padding: 0 16px calc(4px + env(safe-area-inset-bottom)); background: var(--bg); }
.composer {
  width: min(100%, 768px); margin: 0 auto;
  border-radius: 28px; background: var(--composer-bg); box-shadow: var(--composer-shadow);
  cursor: text;
}
.composer textarea {
  display: block; width: 100%; min-height: 52px; max-height: 38dvh;
  padding: 16px 20px 4px; resize: none; overflow-y: auto;
  border: 0; outline: none; background: transparent; color: var(--text);
  font-size: 16px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer textarea:disabled { cursor: not-allowed; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 16px 7px; }
.attachment-preview { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 5px 7px 5px 11px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 12px; }
.attachment-preview span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-preview button { flex: none; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--text-2); font-size: 18px; line-height: 1; }
.attachment-preview button:hover { background: var(--hover); }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 10px 10px 12px; }
.composer-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
.attach-button { display: grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); }
.attach-button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.attach-button:disabled { opacity: .4; }
.attach-button svg { width: 18px; height: 18px; }
.composer-actions { display: flex; align-items: center; gap: 8px; }
.context-indicator { display: grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 3px; border: 0; border-radius: 50%; background: transparent; }
.context-indicator svg { width: 20px; height: 20px; fill: none; stroke-width: 2.6; }
.context-track { stroke: var(--border); }
.context-used { stroke: var(--text-3); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; stroke-dasharray: 56.55; stroke-dashoffset: 56.55; transition: stroke-dashoffset .25s ease; }
.context-indicator.cache-expired .context-used { stroke: var(--yellow); }
.context-indicator.cache-expired .context-track { stroke: color-mix(in srgb, var(--yellow) 30%, transparent); }
.fast-bolt svg { width: 21px; height: 21px; stroke-width: 1.7; transition: fill .15s ease, color .15s ease, transform .2s cubic-bezier(.2,.8,.2,1); }
.fast-bolt[aria-checked="true"] { color: var(--blue); }
.fast-bolt[aria-checked="true"]:hover:not(:disabled) { color: var(--blue); }
.fast-bolt[aria-checked="true"] svg { fill: currentColor; stroke-width: 1; animation: bolt-on .28s cubic-bezier(.2,.8,.2,1); }
@keyframes bolt-on { 40% { transform: scale(1.22) rotate(-6deg); } }
/* Mode chip + panel (same design as the Android app) */
.mode-chip { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 12px; border: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--blue) 13%, transparent); color: var(--blue); font-size: 13px; font-weight: 500; white-space: nowrap; }
.mode-chip:hover:not(:disabled) { background: color-mix(in srgb, var(--blue) 20%, transparent); }
.mode-chip.codex { padding-left: 9px; }
.mode-chip .bolt { display: none; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.mode-chip.codex .bolt { display: block; }
.mode-chip.fast .bolt { fill: currentColor; }
.mode-chip.warn { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.mode-chip.warn:hover:not(:disabled) { background: color-mix(in srgb, var(--amber) 24%, transparent); }
.mode-chip:disabled { opacity: .5; }
.mode-chip.inherited { background: var(--surface-2); color: var(--text-2); }
.mode-chip.inherited:hover:not(:disabled) { background: var(--active); }
.mode-panel { position: absolute; z-index: 12; bottom: calc(100% - 8px); left: max(8px, calc((100% - 800px) / 2)); width: min(460px, calc(100% - 16px));
  padding: 44px 14px 10px; background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 0%, transparent), color-mix(in srgb, var(--bg) 92%, transparent) 38%, var(--bg));
  animation: popover-in .14s ease-out; }
@keyframes popover-in { from { opacity: 0; transform: translateY(6px); } }
.mode-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; margin-bottom: 14px; }
.fast-bolt { position: absolute; left: 0; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); }
.fast-bolt:hover:not(:disabled) { background: var(--hover); }
.fast-bolt:disabled { opacity: .35; }
.fast-bolt svg { width: 23px; height: 23px; stroke-width: 1.7; transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.fast-bolt[aria-checked="true"] { color: var(--blue); }
.fast-bolt[aria-checked="true"] svg { fill: currentColor; stroke-width: 1; animation: bolt-on .28s cubic-bezier(.2,.8,.2,1); }
@keyframes bolt-on { 40% { transform: scale(1.22) rotate(-6deg); } }
.mode-model { display: inline-flex; align-items: baseline; gap: 8px; max-width: calc(100% - 96px); padding: 4px 10px; border: 0; border-radius: 12px; background: transparent; color: var(--text); font-size: 21px; }
.mode-model:hover:not(:disabled) { background: var(--hover); }
.mode-model strong { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.mode-model span { flex: none; color: var(--text-3); font-weight: 500; }
.mode-model svg { flex: none; align-self: center; width: 19px; height: 19px; color: var(--text-2); }
.effort-pill { --pos: 0; position: relative; height: 60px; border-radius: 999px; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.06); cursor: pointer; touch-action: none; }
.effort-pill:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.effort-pill[aria-disabled="true"] { cursor: default; }
.effort-pill[aria-disabled="true"] > * { opacity: .5; }
.effort-pill-fill { position: absolute; top: 8px; bottom: 8px; left: 8px; width: calc(44px + (100% - 60px) * var(--pos)); border-radius: 999px; background: var(--blue); transition: width .24s cubic-bezier(.2,.8,.2,1); }
.effort-pill-dots i { position: absolute; top: 50%; left: calc(30px + (100% - 60px) * var(--dot-pos)); width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: color-mix(in srgb, var(--slider-dot) 60%, transparent); transition: background-color .2s ease; }
.effort-pill-dots i.passed { background: rgba(255, 255, 255, .38); }
.effort-pill-dots i.current { opacity: 0; }
.effort-pill-knob { position: absolute; top: 12px; left: calc(12px + (100% - 60px) * var(--pos)); width: 36px; height: 36px; border-radius: 50%; background: #fff; transition: left .24s cubic-bezier(.2,.8,.2,1), transform .15s ease; }
.effort-pill.dragging .effort-pill-knob { transform: scale(.92); }
.mode-picker { border: 1px solid var(--border); border-radius: 22px; background: var(--bg); box-shadow: 0 12px 36px rgba(0,0,0,.14); overflow: hidden; }
.mode-picker-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 48px; }
.mode-picker-head .icon-button { position: absolute; left: 4px; }
.mode-picker-head strong { font-size: 15px; font-weight: 600; }
.mode-picker-body { max-height: min(420px, 55vh); overflow-y: auto; padding-bottom: 8px; }
.mode-picker-label { margin: 8px 18px 2px; color: var(--text-3); font-size: 12px; font-weight: 500; }
.mode-option { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 18px; border: 0; background: transparent; color: var(--text); text-align: left; }
.mode-option:hover:not(:disabled) { background: var(--hover); }
.mode-option:disabled { opacity: .45; }
.mode-option-text { flex: 1; min-width: 0; }
.mode-option-text strong { display: block; font-size: 15px; font-weight: 400; }
.mode-option-text small { display: block; margin-top: 1px; color: var(--text-3); font-size: 12px; line-height: 1.4; }
.mode-option.warning strong { color: var(--amber); }
.mode-option svg { flex: none; width: 19px; height: 19px; }
.model-status { margin: 10px 2px 0; color: var(--text-3); font-size: 12px; line-height: 1.4; text-align: center; }
.model-status:empty { display: none; }
.model-status[data-error] { color: var(--red); }
@media (prefers-color-scheme: dark) { .effort-pill { background: var(--surface-2); box-shadow: 0 10px 30px rgba(0,0,0,.45); } }
.send-button, .stop-button {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  transition: background .15s ease, opacity .15s ease;
}
.send-button svg { width: 20px; height: 20px; stroke-width: 2.2; }
.send-button:hover:not(:disabled), .stop-button:hover { background: var(--accent-hover); }
.send-button:disabled { background: var(--send-disabled); color: var(--send-disabled-text); }
/* 以英文发送: shown above the send arrow while it is hovered, if there is text to send. */
.send-wrap { position: relative; display: inline-flex; }
.send-wrap::before { position: absolute; right: 0; bottom: 100%; left: 0; height: 10px; content: ''; }
.send-english {
  position: absolute; bottom: calc(100% + 8px); left: 0; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  opacity: 0; pointer-events: none; transform: translateY(4px); transition: opacity .12s ease, transform .12s ease;
}
.send-english:hover { background: var(--hover); }
.composer:not(:has(#prompt:placeholder-shown)) .send-wrap:hover:has(#send-prompt:not(:disabled):not(.hidden)) .send-english,
.send-english.busy { opacity: 1; pointer-events: auto; transform: none; }
.send-english.busy svg { animation: send-english-pulse 1s ease-in-out infinite; }
@keyframes send-english-pulse { 50% { opacity: .35; } }
.send-english-badge {
  position: absolute; top: -5px; right: -6px; padding: 0 3px; border-radius: 5px; background: var(--text); color: var(--bg);
  font-size: 9px; font-weight: 700; line-height: 13px; letter-spacing: .02em;
}
.send-wrap:has(#send-prompt.hidden) { display: none; }
.stop-button svg { width: 18px; height: 18px; }
.stop-button svg rect { fill: currentColor; stroke: none; }
.composer-hint { margin: 0; padding: 8px 12px 6px; overflow: hidden; color: var(--text-3); font-size: 12px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

/* Workspace picker */
.workspace-dialog {
  width: min(92vw, 520px); max-height: 82dvh; padding: 0; overflow: hidden;
  border: 0; border-radius: 20px;
  background: var(--bg); color: var(--text); box-shadow: var(--elevated-shadow);
}
.workspace-dialog::backdrop { background: var(--shade); }
.workspace-dialog-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px; border-bottom: 1px solid var(--border-light); }
.workspace-dialog-head > div { flex: 1; min-width: 0; text-align: center; }
.workspace-dialog-head strong { display: block; font-size: 16px; font-weight: 600; }
.workspace-dialog-head small { display: block; margin-top: 2px; overflow: hidden; color: var(--text-3); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.workspace-list { min-height: 160px; max-height: 55dvh; padding: 8px; overflow-y: auto; }
.workspace-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 44px; padding: 8px 12px;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--text);
  text-align: left; font-size: 15px; overflow-wrap: anywhere;
}
.workspace-row:hover { background: var(--surface-2); }
.workspace-row svg { width: 19px; height: 19px; color: var(--text-2); }
.workspace-row .chev { width: 16px; height: 16px; margin-left: auto; color: var(--text-3); }
.workspace-dialog-footer { padding: 12px 16px 16px; }
.workspace-dialog-footer .primary { min-height: 44px; }

/* 账号设置 (account.js) */
.account-dialog[open] { display: flex; flex-direction: column; }
.account-body { display: grid; flex: 1; gap: 22px; min-height: 0; padding: 16px; overflow-y: auto; }
.account-section { display: grid; gap: 10px; }
.account-section h3 { margin: 0; font-size: 15px; font-weight: 600; }
.account-form { display: grid; gap: 8px; }
.account-form input, .totp-code input {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px;
  outline: none; background: var(--bg); color: var(--text); font-size: 15px;
}
.account-form input:focus, .totp-code input:focus { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.account-dialog .primary, .account-dialog .secondary { min-height: 42px; }
.account-status { min-height: 0; margin: 0; }
.account-status:empty { display: none; }
.account-status.ok { color: var(--green); }
.account-legacy { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; color: var(--amber); font-size: 13px; line-height: 1.45; }
.account-legacy span { flex: 1; }
.device-list { display: grid; gap: 6px; }
.device-row { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px; border: 1px solid var(--border-light); border-radius: 12px; }
.device-text { flex: 1; min-width: 0; }
.device-title { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.device-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-badge { flex: none; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 11px; }
.device-text small { display: block; overflow: hidden; color: var(--text-3); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.totp-box { display: grid; justify-items: start; gap: 10px; }
.totp-status { margin: 0; color: var(--text-2); font-size: 14px; }
.totp-status.on { color: var(--green); }
.totp-box .field-hint { margin: 0; }
.totp-secret { max-width: 100%; padding: 8px 12px; border-radius: 10px; background: var(--code-bg); font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; overflow-wrap: anywhere; user-select: all; }
.totp-link { color: var(--blue); font-size: 13px; }
.totp-code { display: flex; gap: 8px; width: 100%; }
.totp-code input { flex: 1; }
/* The code is always dark on white, whatever the theme: scanners need the contrast. */
.qr { width: 176px; height: 176px; border-radius: 8px; background: #fff; stroke: none; shape-rendering: crispEdges; }
.qr path { fill: #000; }

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
@keyframes execution-dots { from { width: 0; } to { width: 3ch; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

@media (max-width: 760px) {
  .mobile-only { display: grid; }
  .sidebar {
    position: fixed; z-index: 20; inset: 0 auto 0 0;
    width: min(85vw, 320px); height: 100dvh;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    transform: translateX(-100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .sidebar-shade { position: fixed; z-index: 19; inset: 0; background: var(--shade); }
  .topbar { height: 52px; gap: 4px; padding: 0 8px; padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
  .title-wrap { flex-direction: column; align-items: flex-start; gap: 0; }
  .title-heading { max-width: 100%; }
  .title-wrap h2 { max-width: 100%; font-size: 16px; line-height: 1.3; }
  .title-wrap span { max-width: 100%; font-size: 11.5px; line-height: 1.3; }
  .ghost-pill { min-height: 32px; padding: 4px 10px; font-size: 12.5px; }
  .connection { padding: 0 6px; }
  .connection #connection-text { display: none; }
  .messages { padding: 16px 16px 32px 38px; }
  .prompt-rail { top: 50%; left: 0; }
  .prompt-preview { left: 38px; width: min(300px, calc(100vw - 50px)); }
  .message.user { max-width: 85%; }
  .diff-box { padding: 0 16px 16px; }
  .approvals { padding: 4px 10px 8px; }
  .approval { padding: 14px 16px; border-radius: 18px; }
  .approval-actions button { flex: 1; }
  .composer-wrap { padding: 0 10px calc(2px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 26px; }
  .composer textarea { min-height: 48px; padding: 14px 16px 2px; }
  .composer-bottom { padding: 2px 8px 8px 10px; }
  .composer-hint { padding: 6px 12px 4px; font-size: 11px; }
  .empty-state h2 { font-size: 24px; }
  .workspace-dialog { width: 94vw; }
}
@media (max-width: 380px) {
  .ghost-pill { padding-inline: 8px; font-size: 12px; }
  .connection { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Claude Code sessions (web/claude.js) */
/* Long workspace paths must not widen the sidebar grid past 260px. */
.project-block { grid-template-columns: minmax(0, 1fr); }
.claude-note { margin: 4px 0 14px; color: var(--text-3); font-size: 13px; text-align: center; }
.approval-reason {
  width: 100%; height: 38px; margin-top: 10px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 12px; outline: none;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.approval-reason:focus { border-color: var(--text-3); }
.approval-actions { flex-wrap: wrap; }
.approval-plan { max-height: 260px; overflow: auto; padding: 10px 14px; border: 1px solid var(--border-light); border-radius: 12px; background: var(--code-bg); font-size: 14px; }
.approval-question { margin-top: 10px; }
.approval-question small { color: var(--text-3); font-size: 12px; }
.approval-question p { margin: 2px 0 8px; color: var(--text); font-size: 14px; }
.approval-options { display: flex; flex-wrap: wrap; gap: 6px; }
.option-chip {
  min-height: 34px; padding: 4px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--text); font-size: 14px;
}
.option-chip.selected { border-color: var(--text); background: var(--text); color: var(--bg); }
.new-session-body { display: grid; gap: 10px; padding: 14px 16px 4px; }
.dialog-spacer { width: 36px; }
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--hover); }
.segmented button {
  flex: 1; min-height: 40px; border: 0; border-radius: 11px;
  background: transparent; color: var(--text-2); font-size: 15px;
}
.segmented button.active { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.segmented .agent-choice { display: grid; place-items: center; }
.segmented .agent-choice svg { width: 22px; height: 22px; fill: currentColor; stroke: none; opacity: .55; }
.segmented .agent-choice.active svg { opacity: 1; }
.segmented .agent-choice.claude.active { color: #d97757; }
.new-claude-options { display: grid; gap: 10px; }
.field-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 14px; background: transparent; color: var(--text); text-align: left; font-size: 15px;
}
button.field-row:hover { background: var(--surface-2); }
.field-row .field-label { flex: none; color: var(--text-2); font-size: 14px; }
.field-row .field-value { flex: 1; min-width: 0; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.field-row svg { width: 16px; height: 16px; color: var(--text-3); }
.field-row select { flex: 1; min-width: 0; height: 34px; border: 0; background: transparent; color: var(--text); font-size: 15px; text-align: right; text-align-last: right; }
.field-hint { margin: 0; color: var(--text-3); font-size: 12px; }
.new-session-body .error { margin: 0; min-height: 0; }
.branch-dialog { width: min(550px, calc(100vw - 24px)); max-height: min(84vh, 700px); padding: 20px; border: 1px solid var(--border); border-radius: 22px; background: var(--bg); color: var(--text); }
.branch-dialog::backdrop { background: rgba(0, 0, 0, .42); }
.branch-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 18px; }
.branch-head .icon-button { font-size: 26px; }
.branch-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.branch-actions button { min-height: 36px; }
.branch-dialog .error { min-height: 18px; margin: 8px 0 0; }
.branch-confirm { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; }
@media (prefers-color-scheme: dark) {
  .segmented button.active { background: var(--surface-2); }
}

/* Sidebar: user projects */
.label-action { display: grid; place-items: center; width: 24px; height: 24px; margin: -4px -4px -4px 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); }
.label-action:hover { background: var(--hover); color: var(--text); }
.label-action svg { width: 16px; height: 16px; }
.project-list:empty::after { display: block; padding: 4px 8px 8px; color: var(--text-3); content: '点 + 新建项目，把相关会话放在一起'; font-size: 12px; }
.project-group { margin-bottom: 1px; }
.project-head { display: flex; align-items: center; min-width: 0; border-radius: 10px; }
.project-head:hover { background: var(--hover); }
.project-toggle {
  display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; min-height: 36px; padding: 6px 8px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: 14px; text-align: left;
}
.project-icon { width: 18px; height: 18px; flex: none; color: var(--text-2); }
.project-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-done { display: inline-flex; flex: none; align-items: center; gap: 2px; color: var(--green); font-size: 12px; }
.project-done svg { width: 14px; height: 14px; stroke-width: 2; }
.project-action { display: grid; flex: none; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); opacity: 0; }
.project-head:hover .project-action, .project-action:focus-visible { opacity: 1; }
.project-action:hover { background: var(--active); color: var(--text); }
.project-action svg { width: 16px; height: 16px; }
.project-sessions { padding-left: 16px; }
.project-empty { margin: 2px 8px 8px; color: var(--text-3); font-size: 12px; }
.project-more { display: block; width: 100%; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); font-size: 12px; text-align: left; }
.project-more:hover { background: var(--hover); color: var(--text); }
@media (hover: none) { .project-action { opacity: 1; } }

/* Inline project name field */
.project-edit { display: flex; align-items: center; gap: 4px; min-width: 0; padding: 2px 0; }
.project-edit-field {
  display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; height: 34px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.project-edit-field:focus-within { border-color: var(--focus); }
.project-edit-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; }
.project-edit-save, .project-edit-cancel { display: grid; flex: none; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; }
.project-edit-save { background: var(--accent); color: var(--accent-text); }
.project-edit-save:disabled { opacity: .3; }
.project-edit-cancel { background: transparent; color: var(--text-3); }
.project-edit-cancel:hover { background: var(--hover); color: var(--text); }
.project-edit svg { width: 16px; height: 16px; }
.project-edit-save svg { stroke-width: 2.2; }

/* Popover menu for session / project actions */
.row-menu {
  position: fixed; z-index: 60; min-width: 200px; max-width: min(280px, calc(100vw - 16px)); max-height: 60dvh; padding: 6px; overflow-y: auto;
  border: 1px solid var(--border-light); border-radius: 14px; background: var(--bg); box-shadow: var(--elevated-shadow);
  animation: popover-in .12s ease-out;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 14px; text-align: left;
}
.menu-item:hover { background: var(--hover); }
.menu-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item svg { width: 17px; height: 17px; flex: none; color: var(--text-2); }
.menu-item .menu-check { color: var(--text); }
.menu-item.danger, .menu-item.danger svg { color: var(--red); }
.menu-label { padding: 6px 10px 2px; color: var(--text-3); font-size: 12px; }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border-light); }

/* Workspace picker: new folder */
.workspace-actions { display: flex; gap: 8px; }
.workspace-actions .secondary { flex: none; min-height: 44px; }
.workspace-mkdir { display: flex; gap: 8px; margin-bottom: 10px; }
.workspace-mkdir input {
  flex: 1; min-width: 0; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); font-size: 15px;
}
.workspace-mkdir input:focus { outline: none; border-color: var(--focus); }
.workspace-mkdir-error { margin: -4px 0 10px; color: var(--red); font-size: 13px; }

/* Claude subagents: one row in the conversation, chips above the composer, a read-only view */
.message.subagent-card { margin: 4px 0 10px; }
.subagent-open {
  display: flex; align-items: center; gap: 12px; width: 100%; max-width: 560px; padding: 10px 12px;
  border: 1px solid var(--border-light); border-radius: 16px; background: var(--bg); color: var(--text); text-align: left;
  transition: background .15s ease, border-color .15s ease;
}
.subagent-open:hover { background: var(--hover); border-color: var(--border); }
.subagent-avatar {
  position: relative; display: grid; flex: none; place-items: center; width: 34px; height: 34px;
  border-radius: 50%; background: var(--surface-2); color: var(--text-2);
}
.subagent-avatar svg { width: 18px; height: 18px; }
.subagent-card.running .subagent-avatar::after {
  position: absolute; inset: -2px; border: 2px solid transparent; border-top-color: var(--text-2); border-radius: 50%;
  content: ''; animation: subagent-spin 1s linear infinite;
}
.subagent-main { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.subagent-title { overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.subagent-sub { overflow: hidden; margin-top: 2px; color: var(--text-3); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.subagent-card.failed .subagent-sub { color: var(--red); }
.subagent-time { flex: none; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.subagent-chev { flex: none; width: 16px; height: 16px; color: var(--text-3); }
@keyframes subagent-spin { to { transform: rotate(360deg); } }

.subagent-strip { display: flex; gap: 6px; width: min(100%, 768px); margin: 0 auto 8px; overflow-x: auto; scrollbar-width: none; }
.subagent-strip::-webkit-scrollbar { display: none; }
.subagent-chip {
  display: inline-flex; flex: none; align-items: center; gap: 6px; max-width: 260px; min-height: 30px; padding: 4px 10px 4px 8px;
  border: 1px solid var(--border-light); border-radius: 999px; background: var(--bg); color: var(--text-2); font-size: 12.5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.subagent-chip:hover { background: var(--hover); color: var(--text); }
.subagent-spinner { flex: none; width: 12px; height: 12px; border: 1.5px solid var(--border); border-top-color: var(--text-2); border-radius: 50%; animation: subagent-spin 1s linear infinite; }
.subagent-chip-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subagent-chip-time { flex: none; color: var(--text-3); font-variant-numeric: tabular-nums; }

.subagent-view { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.subagent-view-head {
  display: flex; align-items: center; gap: 8px; width: min(100%, 800px); margin: 0 auto; padding: 6px 12px;
  border-bottom: 1px solid var(--border-light);
}
.subagent-view-heading { display: flex; flex-direction: column; min-width: 0; }
.subagent-view-heading strong { overflow: hidden; font-size: 15px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.subagent-view-heading small { margin-top: 1px; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.subagent-view.running .subagent-view-heading small::before {
  display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--yellow);
  content: ''; vertical-align: 1px; animation: running-blink 1.2s ease-in-out infinite;
}
.subagent-view .conversation { flex: 1; min-height: 0; }
.subagent-task .body.clamped { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 6; cursor: pointer; }
.subagent-view-foot { flex: none; margin: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); color: var(--text-3); font-size: 12px; text-align: center; }
@media (prefers-reduced-motion: reduce) { .subagent-spinner, .subagent-card.running .subagent-avatar::after { animation: none; } }

/* /btw side answer above the composer */
.btw-panel {
  width: min(100%, 768px); margin: 0 auto 8px; overflow: hidden;
  border: 1px solid var(--border-light); border-radius: 18px; background: var(--bg); box-shadow: var(--composer-shadow);
}
.btw-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 14px; }
.btw-tag { flex: none; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font: 12px/1.5 var(--mono); }
.btw-question { flex: 1; min-width: 0; overflow: hidden; color: var(--text); font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.btw-close { display: grid; flex: none; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); }
.btw-close:hover { background: var(--hover); color: var(--text); }
.btw-close svg { width: 16px; height: 16px; }
.btw-body { max-height: min(38dvh, 320px); padding: 0 14px; overflow-y: auto; }
.btw-answer { font-size: 14.5px; line-height: 1.6; }
.btw-answer > :first-child { margin-top: 0; }
.btw-answer > :last-child { margin-bottom: 0; }
.btw-status { margin: 0; padding: 6px 14px 10px; color: var(--text-3); font-size: 12px; }
.btw-panel.running .btw-status::before {
  display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 1.5px solid var(--border); border-top-color: var(--text-2);
  border-radius: 50%; content: ''; vertical-align: -1px; animation: subagent-spin 1s linear infinite;
}

/* Foldable sidebar sections */
.section-toggle {
  display: inline-flex; align-items: center; gap: 4px; margin: -4px -6px; padding: 4px 6px;
  border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit;
}
.section-toggle:hover { background: var(--hover); color: var(--text-2); }
.section-chev { width: 13px; height: 13px; transform: rotate(90deg); transition: transform .15s ease; opacity: 0; }
.section-toggle:hover .section-chev, .folded .section-chev, .section-toggle:focus-visible .section-chev { opacity: 1; }
.folded .section-chev { transform: none; }
.folded > nav, .folded > .history-edge { display: none !important; }
@media (hover: none) { .section-chev { opacity: 1; } }

/* Drop a file on the composer */
.composer.drop-target { position: relative; outline: 2px dashed var(--text-3); outline-offset: 3px; }
.composer.drop-target::after {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit;
  background: color-mix(in srgb, var(--bg) 88%, transparent); color: var(--text-2); content: '松开以添加文件'; font-size: 14px;
}

/* Motion: new messages and folding */
@keyframes appear-up { from { opacity: 0; transform: translateY(6px); } }
.messages > .appear { animation: appear-up .22s cubic-bezier(.2, .7, .3, 1); }
.message.user.pending .body { opacity: .6; }
.message.user.pending.sent .body { opacity: .85; }
.message.user.pending::after {
  display: block; margin-top: 4px; color: var(--text-3); content: '发送中…'; font-size: 11.5px; text-align: right;
}
.message.user.pending.sent::after { content: '已发送，等待 Claude 接收…'; }
.bubble-attachment { margin-top: 4px; color: var(--text-3); font-size: 12px; text-align: right; }
.section-chev { transition: transform .18s ease, opacity .15s ease; }
.project-icon { transition: transform .18s ease; }
@media (prefers-reduced-motion: reduce) {
  .messages > .appear { animation: none; }
}
@keyframes fold-open { from { opacity: 0; transform: translateY(-4px); } }
.project-sessions.appear { animation: fold-open .2s cubic-bezier(.2, .7, .3, 1); }
.folding .section-chev { transform: none; opacity: 1; }

/* Inline notice under a risky choice (full access) */
.field-warning { display: flex; gap: 6px; margin: -2px 2px 4px; color: var(--amber); font-size: 12.5px; line-height: 1.45; }
.field-warning::before { flex: none; content: '⚠'; }

/* Bottom tab strip (网络 / 文件 / opened tabs) and its panel */
.composer-hint { display: none; }
.dock-tabs {
  display: flex; gap: 4px; width: min(100%, 768px); margin: 6px auto 4px; padding: 0 2px;
  overflow-x: auto; scrollbar-width: none;
}
.dock-tabs::-webkit-scrollbar { display: none; }
.dock-tab {
  display: inline-flex; flex: none; align-items: center; gap: 5px; max-width: 200px; height: 28px; padding: 0 9px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-3); font-size: 12.5px;
  transition: background .15s ease, color .15s ease;
}
.dock-tab:hover { background: var(--hover); color: var(--text); }
.dock-tab { -webkit-touch-callout: none; user-select: none; }
.dock-tab.dragging { opacity: .6; cursor: grabbing; }
.dock-tab.active { border-color: var(--border-light); background: var(--surface-2); color: var(--text); }
.dock-tab svg { width: 15px; height: 15px; flex: none; }
.dock-tab-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-tab-close { display: grid; place-items: center; width: 16px; height: 16px; margin-right: -4px; border-radius: 4px; opacity: .6; }
.dock-tab-close:hover { background: var(--active); opacity: 1; }
.dock-tab-close svg { width: 12px; height: 12px; }
.dock-tab.fixed + .dock-tab:not(.fixed) { margin-left: 6px; }

.dock-panel {
  position: relative; display: flex; flex: none; flex-direction: column; height: var(--dock-height, 42vh);
  width: min(calc(100% - 24px), 900px); margin: 0 auto 8px;
  border: 1px solid var(--border-light); border-radius: 16px; background: var(--bg); box-shadow: var(--elevated-shadow);
  animation: appear-up .2s cubic-bezier(.2, .7, .3, 1);
}
.dock-panel.maximized { flex: 1; min-height: 0; width: auto; height: auto; margin: 0 16px 6px; }
/* Maximized, the panel spans from the top of the conversation down over the composer; only the tab strip stays below. */
.main:has(> .dock-panel.maximized:not(.hidden)) #composer-wrap > :not(#dock-tabs) { display: none; }
.main:has(> .dock-panel.maximized:not(.hidden)) > :is(.conversation, .subagent-view) { flex: 0 0 0; overflow: hidden; visibility: hidden; }
.main:has(> .dock-panel.maximized:not(.hidden)) > :is(.empty-state, .prompt-rail, .prompt-preview) { display: none; }
.dock-panel.maximized .dock-resize { display: none; }
.dock-panel.maximized .dock-markdown { max-width: 900px; margin: 0 auto; }
.dock-panel.maximized .dock-image, .dock-panel.maximized .dock-video { max-height: calc(100dvh - 280px); }
.dock-windows { position: fixed; inset: 0; z-index: 16; pointer-events: none; }
.dock-window {
  position: fixed; display: flex; flex-direction: column; min-width: 280px; min-height: 160px; pointer-events: auto;
  border: 1px solid var(--border); border-radius: 14px; background: var(--bg); box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
  overflow: hidden; animation: appear-up .16s cubic-bezier(.2, .7, .3, 1);
}
.dock-window-head { cursor: grab; user-select: none; }
.dock-heading strong:empty { display: none; }
.dock-window-moving, .dock-window-moving * { cursor: grabbing !important; user-select: none; }
.dock-window-moving iframe { pointer-events: none; }
.dock-window .dock-frame { border-radius: 0; }
.dock-window .dock-actions { opacity: 0; transition: opacity .15s ease; }
.dock-window:hover .dock-actions, .dock-window:focus-within .dock-actions { opacity: 1; }
.dock-window-edge { position: absolute; top: 0; right: 0; bottom: 18px; width: 6px; cursor: ew-resize; }
.dock-window .dock-image, .dock-window .dock-video { max-height: 100%; }
.dock-window-grip { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 55%, var(--border) 55%, var(--border) 62%, transparent 62%, transparent 75%, var(--border) 75%, var(--border) 82%, transparent 82%); }
.dock-resize { position: absolute; top: -6px; left: 0; right: 0; height: 12px; cursor: ns-resize; touch-action: none; }
.dock-resize::after { position: absolute; top: 4px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border); content: ''; }
.dock-head { display: flex; align-items: center; gap: 8px; flex: none; padding: 10px 8px 8px 14px; border-bottom: 1px solid var(--border-light); }
.dock-heading { display: flex; flex: 1; align-items: baseline; gap: 8px; min-width: 0; }
.dock-heading strong { flex: none; max-width: 50%; overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.dock-heading small { min-width: 0; overflow: hidden; color: var(--text-3); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.dock-actions { display: flex; flex: none; gap: 2px; }
.dock-action { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); }
.dock-action:hover { background: var(--hover); color: var(--text); }
.dock-action svg { width: 16px; height: 16px; }
.dock-body { flex: 1; min-height: 0; overflow: auto; }
.dock-content { min-height: 100%; padding: 12px 14px; }
.dock-content.flush { height: 100%; padding: 0; }
.dock-content.center { display: grid; place-items: center; }
.dock-frame { display: block; width: 100%; height: 100%; border: 0; border-radius: 0 0 16px 16px; background: #fff; }
.dock-image { max-width: 100%; max-height: calc(var(--dock-height, 42vh) - 80px); border-radius: 8px; }
.dock-video { max-width: 100%; max-height: calc(var(--dock-height, 42vh) - 80px); }
.dock-audio { width: min(100%, 480px); }
.dock-note { margin: 4px 0 10px; color: var(--text-3); font-size: 13px; }
.dock-note.error { color: var(--red); }
.dock-port-form { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dock-port-form label { display: flex; flex: 1; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 12px; color: var(--text-3); font: 13px var(--mono); }
.dock-port-form label:focus-within { border-color: var(--focus); }
.dock-port-form input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: 14px var(--mono); }
.dock-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.dock-chip { height: 28px; padding: 0 10px; border: 1px solid var(--border-light); border-radius: 999px; background: transparent; color: var(--text-2); font: 12.5px var(--mono); }
.dock-chip:hover { background: var(--hover); color: var(--text); }
.dock-crumbs { display: flex; flex-wrap: wrap; align-items: center; margin-bottom: 6px; font: 12.5px var(--mono); }
.dock-crumb { padding: 2px 4px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font: inherit; }
.dock-crumb:hover { background: var(--hover); color: var(--text); }
.dock-crumb-sep { color: var(--text-3); }
.dock-file-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.dock-file-tools .dock-crumb { font-family: var(--font); font-size: 12px; }
.dock-toggle { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; color: var(--text-3); font-size: 12px; }
.dock-files { display: flex; flex-direction: column; }
.dock-file {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 4px 8px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 13.5px; text-align: left;
}
.dock-file:hover { background: var(--hover); }
.dock-file svg { width: 16px; height: 16px; flex: none; color: var(--text-3); }
.dock-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-file-meta { flex: none; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.dock-file.hidden-file { opacity: .6; }
.dock-file-row { display: flex; align-items: center; }
.dock-file-row .dock-file { flex: 1; min-width: 0; }
.dock-file-download { display: grid; flex: none; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); }
.dock-file-download:hover { background: var(--hover); color: var(--text); }
.dock-file-download svg { width: 16px; height: 16px; }
.dock-transfers { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.dock-transfer { padding: 8px 10px; border: 1px solid var(--border-light); border-radius: 10px; }
.dock-transfer.error .dock-file-meta { color: var(--red); }
.dock-transfer-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dock-transfer-head svg { width: 15px; height: 15px; flex: none; color: var(--text-3); }
.dock-transfer-bar { height: 4px; margin-top: 7px; overflow: hidden; border-radius: 2px; background: var(--border-light); }
.dock-transfer-bar span { display: block; height: 100%; border-radius: 2px; background: var(--text-2); transition: width .4s ease; }
.dock-code { margin: 0; padding: 0; overflow: visible; background: transparent; font: 12.5px/1.6 var(--mono); white-space: pre; tab-size: 4; }
.dock-code .line { display: block; padding-right: 12px; }
.dock-code .line.target { background: color-mix(in srgb, var(--yellow) 22%, transparent); }
.dock-code .ln { display: inline-block; width: 3.5em; margin-right: 12px; color: var(--text-3); text-align: right; user-select: none; }
.dock-segment { display: inline-flex; gap: 2px; margin-bottom: 8px; padding: 2px; border-radius: 8px; background: var(--hover); }
.dock-segment button { padding: 3px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); font-size: 12px; }
.dock-segment button.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.dock-markdown { font-size: 14px; line-height: 1.65; }

/* Paths in messages: checked on Linux only when clicked */
code.path-candidate, .local-reference code.path { cursor: pointer; text-decoration: underline dotted color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
code.path-candidate:hover, .local-reference code.path:hover { text-decoration-color: currentColor; }
@media (max-width: 760px) {
  .dock-panel { width: calc(100% - 12px); height: var(--dock-height, 50vh); }
  .dock-code { font-size: 11.5px; }
}

/* Session row: title + status on the first line, time on the second; rename by double-click,
   menu by right-click / long-press. A mounted Codex row keeps its × on the time line. */
.thread-row, .mounted-row { position: relative; }
.thread-main { padding-right: 2px; }
.thread small { margin-top: 5px; }
.thread-row .unmount-button {
  position: absolute; z-index: 1; right: 26px; bottom: 5px; width: 24px; height: 20px; margin: 0; border-radius: 6px; font-size: 17px;
}

/* Queue: messages sent when the running turn ends */
.send-button .queue-icon { display: none; }
.send-button.queue-mode .send-icon { display: none; }
.send-button.queue-mode .queue-icon { display: block; }
.queue-panel {
  width: min(100%, 768px); margin: 0 auto 8px; padding: 8px 10px;
  border: 1px dashed var(--border); border-radius: 16px; background: var(--bg);
}
.queue-head { display: flex; align-items: center; gap: 6px; margin: 0 0 4px 2px; color: var(--text-3); font-size: 12px; }
.queue-head svg { width: 14px; height: 14px; }
.queue-item { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 2px 2px 2px 4px; border-radius: 8px; animation: appear-up .18s ease-out; }
.queue-item:hover { background: var(--hover); }
.queue-index { display: grid; flex: none; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); color: var(--text-3); font-size: 11px; }
.queue-text { flex: 1; min-width: 0; overflow: hidden; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.queue-remove { display: grid; flex: none; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); }
.queue-remove:hover { background: var(--active); color: var(--text); }
.queue-remove svg { width: 14px; height: 14px; }

/* Selected text → 收藏 / 引用 */
.selection-bar {
  position: fixed; z-index: 70; display: flex; gap: 2px; padding: 4px;
  border: 1px solid var(--border-light); border-radius: 12px; background: var(--bg); box-shadow: var(--elevated-shadow);
  animation: popover-in .12s ease-out;
}
.selection-bar button {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 13px;
}
.selection-bar button:hover { background: var(--hover); }
.selection-bar svg { width: 16px; height: 16px; }

/* 翻译 card (translate.js) */
.translate-card {
  position: fixed; z-index: 72; display: flex; flex-direction: column; max-height: min(60vh, 520px); overflow: hidden;
  border: 1px solid var(--border-light); border-radius: 14px; background: var(--bg); box-shadow: var(--elevated-shadow);
  animation: popover-in .12s ease-out;
}
.translate-head { display: flex; flex: none; align-items: center; gap: 4px; padding: 8px 8px 6px 12px; border-bottom: 1px solid var(--border-light); }
.translate-lang { height: 28px; padding: 0 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 13px; }
.translate-arrow { color: var(--text-3); font-size: 13px; }
.translate-swap { width: 28px; height: 28px; }
.translate-swap svg, .translate-head .icon-button svg { width: 15px; height: 15px; }
.translate-head .icon-button { width: 28px; height: 28px; }
.translate-status { flex: 1; min-width: 0; overflow: hidden; color: var(--text-3); font-size: 12px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.translate-body { flex: 1; min-height: 44px; overflow-y: auto; padding: 10px 14px; font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.translate-body.pending::after { color: var(--text-3); content: '…'; }
.translate-body.error { color: var(--red); }
.translate-actions { display: flex; flex: none; gap: 2px; padding: 0 8px 8px; }
.translate-actions:empty { display: none; }
.translate-action { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 13px; }
.translate-action:hover { background: var(--hover); }
.translate-action svg { width: 15px; height: 15px; }
.nav-count { margin-left: auto; color: var(--text-3); font-size: 12px; }
#sound-toggle .sound-mute, #sound-toggle.off .sound-waves { display: none; }
#sound-toggle.off .sound-mute { display: inline; }
#sound-toggle.off { color: var(--text-3); }

/* 收藏 list */
.favorites-list { padding: 8px; }
.favorites-empty { margin: 24px 12px; color: var(--text-3); font-size: 14px; text-align: center; }
.favorite-item { display: flex; align-items: flex-start; gap: 4px; border-radius: 12px; }
.favorite-item:hover { background: var(--hover); }
.favorite-open { display: flex; flex: 1; flex-direction: column; gap: 4px; min-width: 0; padding: 10px 12px; border: 0; background: transparent; color: var(--text); text-align: left; }
.favorite-text { display: -webkit-box; overflow: hidden; font-size: 14px; line-height: 1.5; white-space: pre-wrap; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow-wrap: anywhere; }
.favorite-meta { color: var(--text-3); font-size: 12px; }
.favorite-actions { display: flex; gap: 2px; padding: 8px 6px 0 0; opacity: 0; }
.favorite-item:hover .favorite-actions, .favorite-actions:focus-within { opacity: 1; }
.favorite-action { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); }
.favorite-action:hover { background: var(--active); color: var(--text); }
.favorite-action.danger:hover { color: var(--red); }
.favorite-action svg { width: 16px; height: 16px; }
@media (hover: none) { .favorite-actions { opacity: 1; } }
@keyframes flash-bg { 0%, 60% { background: color-mix(in srgb, var(--yellow) 22%, transparent); } 100% { background: transparent; } }
.messages > .flash { border-radius: 12px; animation: flash-bg 2.2s ease-out; }

/* Hover hint for [data-tip] (see app.js); the theme's text and background colours, swapped. */
.hover-tip {
  position: fixed; left: 0; top: 0; z-index: 1000; max-width: 320px; padding: 7px 10px;
  border-radius: 10px; background: var(--text); color: var(--bg);
  font-size: 12px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .16); pointer-events: none; opacity: 0; transition: opacity .12s ease;
}
.hover-tip.visible { opacity: .94; }

/* 笔记: list beside a Notion-style editor; one pane at a time on narrow screens */
.notes-dialog { width: min(640px, calc(100vw - 24px)); height: min(620px, calc(100dvh - 80px)); max-width: none; max-height: none; margin: auto; padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 18px; background: var(--bg); color: var(--text); box-shadow: 0 24px 64px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.06); }
.notes-dialog[open] { display: flex; flex-direction: column; animation: search-in .14s ease-out; }
.notes-dialog::backdrop { background: rgba(0, 0, 0, .28); }
.notes-head { display: flex; flex: none; align-items: center; gap: 6px; min-height: 52px; padding: 4px 8px 4px 18px; border-bottom: 1px solid var(--border-light); }
.notes-head strong { flex: 1; font-size: 15px; font-weight: 600; }
.notes-status { flex: 1; min-width: 0; margin-left: 8px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.notes-dialog > input { flex: none; height: 36px; margin: 10px 10px 4px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; outline: none; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }
.notes-list { flex: 1; overflow-y: auto; padding: 4px 6px 10px; overscroll-behavior: contain; }
.notes-empty { margin: 24px 12px; color: var(--text-3); font-size: 13px; text-align: center; }
.note-card { display: flex; align-items: flex-start; gap: 2px; margin: 2px 0; border-radius: 10px; }
.note-card:hover { background: var(--hover); }
.note-card.active { background: var(--active); }
.note-card .favorite-action { margin: 8px 4px 0 0; opacity: 0; }
.note-card:hover .favorite-action, .note-card .favorite-action:focus-visible { opacity: 1; }
.note-open { display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; padding: 9px 10px; border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.note-card-title { overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.note-card-meta { overflow: hidden; color: var(--text-3); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.note-card.confirming { align-items: center; gap: 6px; padding: 8px 8px 8px 10px; background: var(--surface-2); }
.note-confirm-text { flex: 1; min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.note-confirm { flex: none; height: 28px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--bg); color: var(--text); font-size: 13px; cursor: pointer; }
.note-confirm.danger { background: var(--red); color: #fff; }
.notes-page { max-width: 760px; margin: 0 auto; padding: 20px 40px 30vh; }
/* The open note replaces everything below the top bar; the session underneath comes back when the note is left. */
.note-view { display: none; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--active) transparent; }
.main.note-mode > :not(.topbar, .note-view, .notice, .composer-wrap, .dock-windows, .dock-panel) { display: none !important; }
/* A note keeps the tab strip (and its windows): only the composer's own parts are hidden. */
.main.note-mode > #composer-wrap { display: block !important; }
.main.note-mode > #composer-wrap > :not(#dock-tabs) { display: none !important; }
.main.note-mode > .note-view { display: block; }
.main.note-mode .title-wrap, .main.note-mode .topbar-actions > :not(.connection) { display: none; }
.note-bar { display: none; flex: 1; align-items: center; gap: 8px; min-width: 0; }
.main.note-mode .note-bar { display: flex; }
.note-crumb { overflow: hidden; color: var(--text-2); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.note-bar .notes-status { flex: 1; margin-left: 0; }
.note-bar .icon-button { width: 32px; height: 32px; color: var(--text-3); }
.note-bar .icon-button:hover { color: var(--red); }
.note-title { width: 100%; padding: 0; border: 0; outline: none; background: transparent; color: var(--text); font: 700 30px/1.3 var(--font); }
.note-title::placeholder { color: var(--text-3); }
.note-editor { position: relative; min-height: 50vh; margin-top: 12px; outline: none; font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; caret-color: var(--text); }
.note-editor.is-empty::before { position: absolute; color: var(--text-3); content: '输入内容；行首输入 # 标题、- 列表、1. 编号、[] 待办、> 引用、``` 代码'; pointer-events: none; }
.note-editor > p, .note-editor > [data-b] { margin: 2px 0; }
.note-editor > h1, .note-editor > h2, .note-editor > h3, .note-editor > h4, .note-editor > h5, .note-editor > h6 { margin: 18px 0 4px; }
.note-editor > blockquote { margin: 6px 0; }
.note-editor > hr { margin: 14px 0; cursor: default; }
.note-editor > pre { margin: 8px 0; padding: 12px 14px; border: 1px solid var(--border-light); border-radius: 12px; background: var(--code-bg); font: 13.5px/1.6 var(--mono); white-space: pre-wrap; tab-size: 2; }
.note-editor > pre[data-lang]:not([data-lang=""])::before { display: block; margin-bottom: 4px; color: var(--text-3); content: attr(data-lang); font: 11px var(--font); user-select: none; }
.note-editor > [data-b] { position: relative; padding-left: calc(var(--indent, 0) * 24px + 26px); }
.note-editor > [data-indent="1"] { --indent: 1; } .note-editor > [data-indent="2"] { --indent: 2; } .note-editor > [data-indent="3"] { --indent: 3; }
.note-editor > [data-indent="4"] { --indent: 4; } .note-editor > [data-indent="5"] { --indent: 5; } .note-editor > [data-indent="6"] { --indent: 6; }
.note-editor > [data-b]::before { position: absolute; left: calc(var(--indent, 0) * 24px); width: 22px; color: var(--text-2); text-align: center; user-select: none; }
.note-editor > [data-b="ul"]::before { content: '•'; font-size: 1.1em; }
.note-editor > [data-b="ol"]::before { content: attr(data-n) '.'; font-variant-numeric: tabular-nums; }
.note-editor > [data-b="todo"]::before { top: .38em; left: calc(var(--indent, 0) * 24px + 3px); width: 16px; height: 16px; box-sizing: border-box; border: 1.5px solid var(--text-3); border-radius: 4px; content: ''; cursor: pointer; }
.note-editor > [data-b="todo"][data-checked]::before { border-color: var(--text); background: var(--text); color: var(--bg); content: '✓'; font-size: 12px; font-weight: 700; line-height: 13px; }
.note-editor > [data-b="todo"][data-checked] { color: var(--text-3); text-decoration: line-through; }
.note-editor a { cursor: text; }
@media (max-width: 720px) {
  .notes-dialog { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .notes-page { padding: 18px 18px 40vh; }
  .note-title { font-size: 24px; }
  .note-card .favorite-action { opacity: 1; }
}
@media (hover: none) { .note-card .favorite-action { opacity: 1; } }
/* The note editor's "/" menu */
.slash-menu {
  position: fixed; z-index: 75; display: grid; grid-template-columns: repeat(6, 40px); gap: 4px; padding: 8px;
  border: 1px solid var(--border-light); border-radius: 14px; background: var(--bg); box-shadow: var(--elevated-shadow);
  animation: popover-in .12s ease-out;
}
.slash-item { display: grid; place-items: center; width: 40px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font: 500 16px var(--font); }
.slash-item:hover, .slash-item.active { background: var(--hover); color: var(--text); }
.slash-item svg { width: 21px; height: 21px; }
.slash-item sub { font-size: 10px; }
.slash-link { display: flex; grid-column: 1 / -1; flex-direction: column; gap: 6px; width: 260px; }
.slash-link input { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; outline: none; background: var(--bg); color: var(--text); font: inherit; font-size: 13.5px; }
.slash-link input:focus { border-color: var(--focus); }
.slash-link button { align-self: flex-end; height: 32px; padding: 0 14px; border-radius: 9px; }
/* Archived sessions: a badge on the parent row (left of the agent logo) unfolds them, indented beneath. */
.archive-badge {
  position: absolute; right: 22px; bottom: 5px; display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 5px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.archive-badge:hover { background: var(--active); color: var(--text); }
.archive-badge svg { width: 13px; height: 13px; }
.archive-badge .archive-chevron { width: 12px; height: 12px; transition: transform .15s ease; }
.archive-badge.open .archive-chevron { transform: rotate(180deg); }
.archive-badge .thread-status.running { width: 6px; height: 6px; margin: 0 1px; }
.archive-badge .archive-done { color: var(--green); }
.archive-children { margin-left: 14px; padding-left: 4px; border-left: 1px solid var(--border-light); }
.thread-row.archive-drop > .thread { outline: 2px dashed var(--focus); outline-offset: -2px; }
.project-head.archive-drop, .history-section.archive-drop { outline: 2px dashed var(--focus); outline-offset: -2px; border-radius: 8px; }
