/* RayChat web / desktop client, laid out like the Claude desktop app: a quiet sidebar with the conversation (or
   task) list and the account at the bottom, a warm off-white work surface, a centred column of messages (your
   own in a soft bubble on the right, replies as plain text), and one rounded composer at the bottom. Chat mode
   (bots) and project mode (Claude Code / Codex on a cloud server) share the same shell and the same look. */
:root {
  --bg: #FAF9F5; --side: #F3F1EA; --surface: #FFFFFF; --raised: #FFFFFF;
  --text: #1F1E1B; --text-2: #3D3C38; --muted: #75736C; --faint: #A5A39B;
  --line: #E6E3DA; --line-strong: #D6D3C8; --hover: rgba(31, 30, 27, .05); --active: rgba(31, 30, 27, .085);
  --user: #EFECE3; --code: rgba(31, 30, 27, .065); --menu: #FFFFFF;
  --accent: #D97757; --accent-strong: #BF5A3A; --accent-soft: #F7E6DD; --on-accent: #FFFFFF;
  --link: #2E5E9E; --ok: #3E7B45; --ok-soft: #E3F0E1; --run: #D97757; --wait: #B7791F;
  --danger: #B5413B; --danger-soft: #F8E4E1; --warn: #8A5B0C; --warn-soft: #FBF0D8;
  --toast: #2B2A27; --mascot-bg: #EFEDE6; --scrim: rgba(20, 19, 17, .45);
  --shadow: 0 1px 2px rgba(31, 30, 27, .06); --shadow-md: 0 2px 8px rgba(31, 30, 27, .07), 0 0 0 1px rgba(31, 30, 27, .04);
  --shadow-lg: 0 14px 40px rgba(31, 30, 27, .16), 0 2px 8px rgba(31, 30, 27, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  /* the greeting and the replies of chat mode: a book face for Latin, Songti where the system has it */
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", "Songti SC", "Noto Serif SC", "Source Han Serif SC", "Microsoft YaHei UI", "Microsoft YaHei", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --side-w: 288px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624; --side: #1F1E1C; --surface: #30302D; --raised: #343431;
    --text: #F2F0E8; --text-2: #D3D0C6; --muted: #A09E95; --faint: #75736C;
    --line: #3A3936; --line-strong: #4A4844; --hover: rgba(255, 255, 255, .045); --active: rgba(255, 255, 255, .085);
    --user: #1B1A18; --code: rgba(255, 255, 255, .08); --menu: #30302D;
    --accent: #D97757; --accent-strong: #E58F72; --accent-soft: #46302A; --on-accent: #FFFFFF;
    --link: #8CB4F0; --ok: #7FBF7F; --ok-soft: #233326; --run: #E58F72; --wait: #E5B45A;
    --danger: #EE7B73; --danger-soft: #3E2523; --warn: #F0C46B; --warn-soft: #3A3020;
    --toast: #F2F0E8; --mascot-bg: #EFEDE6; --scrim: rgba(0, 0, 0, .55);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-md: 0 2px 10px rgba(0, 0, 0, .28), 0 0 0 1px rgba(255, 255, 255, .05);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .06);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input, textarea, select { font: inherit; color: var(--text); }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
#app { height: 100%; }
.boot { padding: 48px 16px; text-align: center; color: var(--muted); }
.icon { display: inline-flex; flex: none; }
.bad { color: var(--danger); }
.muted { color: var(--muted); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---------- avatars ---------- */
.av { flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 600; user-select: none; }
.av.mascot { background: var(--mascot-bg); overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: contain; }
.av-group { position: relative; flex: none; display: inline-block; }
.av-group .av { position: absolute; box-shadow: 0 0 0 2px var(--side); }
.av-group .av:first-child { left: 0; top: 0; }
.av-group .av:last-child { right: 0; bottom: 0; }
.av.me { background: var(--text); color: var(--bg); font-size: 13px; }

/* ---------- buttons ---------- */
.pbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 20px; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.pbtn:hover:not(:disabled) { opacity: .88; }
.pbtn:active { opacity: .8; }
.pbtn:disabled { opacity: .45; }
.pbtn.small { height: 32px; padding: 0 14px; border-radius: 8px; font-size: 13.5px; }
.pbtn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.pbtn.ghost:hover:not(:disabled) { background: var(--hover); opacity: 1; }
.pbtn.danger { color: var(--danger); }
.pbtn.block { width: 100%; }
.pbtn.accent { background: var(--accent); color: var(--on-accent); }
.tbtn { height: 36px; padding: 0 14px; border-radius: 8px; color: var(--text); font-weight: 600; font-size: 14px; }
.tbtn:hover:not(:disabled) { background: var(--hover); }
.tbtn.strong { background: var(--text); color: var(--bg); }
.tbtn.strong:hover:not(:disabled) { opacity: .88; }
.tbtn.danger { background: var(--danger); color: #fff; }
.tbtn:disabled { opacity: .45; }
.ib { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); }
.ib:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.ib:disabled { opacity: .4; }
.ib.on { background: var(--active); color: var(--text); }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-strong); font-size: inherit; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.only-narrow { display: none; }

/* ---------- bars ---------- */
.bar { position: relative; z-index: 3; flex: none; display: flex; align-items: center; gap: 4px; height: 52px; padding: 0 10px 0 16px; background: var(--bg); }
.bar h1 { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar.back { padding-left: 8px; }
.bar .who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding-left: 4px; }
.bar .t { min-width: 0; display: flex; flex-direction: column; }
.bar .nm2 { font-size: 15px; font-weight: 600; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .topic { font-weight: 400; color: var(--muted); }
.bar .st { font-size: 12px; line-height: 16px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- shell: sidebar + main ---------- */
.shell { height: 100%; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); background: var(--bg); }
.shell.side-off { grid-template-columns: 0 minmax(0, 1fr); }
.shell.side-off .side { visibility: hidden; }
.side { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--side); border-right: 1px solid var(--line); overflow: hidden; }
.side-top { flex: none; display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 8px 0 16px; }
.brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.brand img { width: 24px; height: 24px; border-radius: 7px; }
.side-open { position: fixed; z-index: 20; left: 10px; top: 9px; background: var(--bg); }
.shell:not(.side-off) .side-open { display: none; }
.modes { flex: none; display: flex; gap: 2px; margin: 0 12px 8px; padding: 3px; border-radius: 10px; background: var(--active); }
.mode { position: relative; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; border-radius: 8px; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.mode:hover { color: var(--text); }
.mode.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.mode .badge { position: absolute; top: 6px; right: 10px; }
.side-nav { flex: none; display: flex; flex-direction: column; gap: 1px; padding: 0 8px 6px; }
.nrow { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border-radius: 9px; color: var(--text-2); font-size: 14px; text-align: left; }
.nrow:hover { background: var(--hover); color: var(--text); }
.nrow.on { background: var(--active); color: var(--text); }
.nrow > .icon { color: var(--muted); }
.nrow.new { color: var(--text); font-weight: 500; }
.nplus { flex: none; width: 24px; height: 24px; margin-left: -2px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.nrow.new:hover .nplus { transform: rotate(90deg); transition: transform .2s; }
.searchbox { position: relative; color: var(--muted); }
.searchbox .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.searchbox input { width: 100%; height: 36px; padding: 0 10px 0 36px; border: 0; border-radius: 9px; background: transparent; outline: none; font-size: 14px; }
.searchbox input::placeholder { color: var(--text-2); }
.searchbox input:hover { background: var(--hover); }
.searchbox input:focus { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.searchbox input:focus::placeholder { color: var(--faint); }
.list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 16px; }
.list-empty { padding: 28px 18px; color: var(--muted); text-align: center; line-height: 1.7; font-size: 13.5px; }
.list-sect { margin-top: 10px; padding: 6px 10px 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.list-sect:first-child { margin-top: 2px; }
.badge { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }

/* a conversation in chat mode's list */
.crow { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 5px 10px; border-radius: 9px; text-align: left; font-size: 14px; color: var(--text-2); }
.crow:hover { background: var(--hover); color: var(--text); }
.crow.on { background: var(--active); color: var(--text); }
.crow .av, .crow .av-group { flex: none; }
.crow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.crow-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 20px; }
.crow-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow-sub.busy { color: var(--run); }
.crow-sub.wait { color: var(--wait); font-weight: 600; }
.crow.unread .crow-title { color: var(--text); font-weight: 600; }
.crow-meta { flex: none; display: inline-flex; align-items: center; gap: 6px; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* the account at the bottom of the sidebar */
.side-foot { flex: none; padding: 6px 8px 0; }
.acct { flex: none; display: flex; align-items: center; gap: 10px; margin: 6px 8px 10px; padding: 7px 8px; border-radius: 10px; text-align: left; }
.acct:hover, .acct[aria-expanded="true"] { background: var(--hover); }
.acct-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.acct-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct > .icon:last-child { color: var(--muted); }

/* ---------- panels in the main area: library, empty states ---------- */
.panel { flex: 1; min-height: 0; overflow-y: auto; }
.panel-inner { max-width: 680px; margin: 0 auto; padding: 20px 20px 56px; display: flex; flex-direction: column; gap: 14px; }
.panel-inner.wide { max-width: 860px; }
.panel-title { font-family: var(--serif); font-size: 28px; font-weight: 500; letter-spacing: -.01em; padding: 18px 2px 4px; }
.sect { font-size: 13px; color: var(--muted); padding: 6px 2px 0; }
.card { background: var(--surface); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-md); }
.card .item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 0 0 0 16px; text-align: left; }
.card .item:hover { background: var(--hover); }
.card .item .info { flex: 1; min-width: 0; display: flex; gap: 8px; padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line); }
.card .item:last-child .info { border-bottom: 0; }
.card .tx { flex: 1; min-width: 0; }
.nm { font-size: 15px; line-height: 21px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv { margin-top: 1px; font-size: 13px; line-height: 18px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .right { flex: none; align-self: center; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.state { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.on { color: var(--ok); }
.state.off { color: var(--muted); }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; gap: 4px; }
.empty .big { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 600; color: var(--accent-strong); margin-bottom: 16px; }
.empty p { color: var(--muted); line-height: 1.7; max-width: 28em; margin-bottom: 20px; }
.lib-item { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.lib-item:last-child { border-bottom: 0; }
.lib-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lib-head strong { font-size: 15.5px; font-weight: 600; }
.lib-desc { color: var(--text-2); font-size: 14px; }
.lib-meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.lib-body { white-space: pre-wrap; font-size: 13.5px; color: var(--text-2); background: var(--bg); border-radius: 8px; padding: 10px 12px; max-height: 220px; overflow-y: auto; }
.chipset { display: flex; flex-wrap: wrap; gap: 8px; }
.tog { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; background: transparent; color: var(--text-2); font-size: 13px; box-shadow: inset 0 0 0 1px var(--line-strong); }
.tog:hover:not(:disabled) { background: var(--hover); }
.tog.on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }
.tog:disabled { cursor: default; opacity: .85; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--active); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent-strong); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- a conversation (both modes) ---------- */
.chat { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chatarea { position: relative; flex: 1; min-height: 0; }
.msgs { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 8px 0 24px; }
.msgs-inner { max-width: 800px; margin: 0 auto; padding: 0 32px; display: flex; flex-direction: column; }
.date { align-self: center; margin: 22px auto 6px; color: var(--faint); font-size: 12px; }
.sysline { align-self: center; margin: 10px auto; padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 12.5px; line-height: 1.5; text-align: center; }
.sysline.bad { background: var(--danger-soft); color: var(--danger); }
.sysline.note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 14px; font-size: 13px; }
button.sysline { cursor: pointer; }
button.sysline:hover:not(:disabled) { color: var(--text); background: var(--hover); }
.banner { flex: none; padding: 6px 16px; background: var(--warn-soft); color: var(--warn); font-size: 13px; text-align: center; }
.welcome { margin: 16vh auto 0; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--muted); max-width: 30em; }
.welcome strong { color: var(--text); font-family: var(--serif); font-size: 24px; font-weight: 500; }
.welcome span { font-size: 14px; line-height: 1.7; }

.msg { position: relative; display: flex; flex-direction: column; }
.msg.u { align-items: flex-end; margin-top: 26px; }
.msg.u:first-child, .date + .msg.u { margin-top: 10px; }
.msg.a { align-items: stretch; margin-top: 14px; }
.msg.u + .msg.a { margin-top: 18px; }
.ubub { position: relative; max-width: min(85%, 620px); padding: 10px 16px; border-radius: 18px; background: var(--user); color: var(--text); font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.ubub .mc.plain { white-space: pre-wrap; }
.ubub .thumbs, .ubub .chips { margin: 2px 0 6px; }
.ubub .thumbs:last-child, .ubub .chips:last-child { margin-bottom: 2px; }
.ubub.sending { opacity: .7; }
.to { font-size: 12.5px; color: var(--accent-strong); margin-bottom: 2px; }
.who-line { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; font-size: 13.5px; font-weight: 600; color: var(--text); }
.abody { min-width: 0; color: var(--text); font-size: 15.5px; line-height: 1.7; overflow-wrap: anywhere; }
.chat-mode .abody { font-family: var(--serif); font-size: 16.5px; line-height: 1.75; }
.chat-mode .abody code, .chat-mode .abody pre, .chat-mode .abody table { font-family: var(--mono); }
.chat-mode .abody table { font-family: var(--font); }
.acts { display: flex; align-items: center; gap: 2px; min-height: 28px; margin-top: 4px; color: var(--muted); font-size: 12px; opacity: 0; transition: opacity .12s; }
.msg.u .acts { justify-content: flex-end; }
.msg:hover .acts, .msg.last .acts, .acts:focus-within { opacity: 1; }
.act { flex: none; width: 28px; height: 28px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.act:hover { background: var(--hover); color: var(--text); }
.acts-time { padding: 0 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.acts-note { padding: 0 6px; }
.fail { align-self: flex-end; margin: 4px 2px 0; font-size: 12.5px; color: var(--danger); display: flex; gap: 10px; align-items: center; }
.jump { position: absolute; left: 50%; bottom: 14px; z-index: 2; width: 36px; height: 36px; margin-left: -18px; border-radius: 50%; background: var(--surface); color: var(--text-2); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg); }

/* markdown */
.mc:empty { min-height: 22px; }
.mc > :first-child { margin-top: 0; }
.mc > :last-child { margin-bottom: 0; }
.mc p { margin: 0 0 .75em; }
.mc h1, .mc h2, .mc h3, .mc h4, .mc h5, .mc h6 { margin: 1.1em 0 .5em; font-size: 1.05em; line-height: 1.4; font-weight: 600; }
.mc h1, .mc h2 { font-size: 1.2em; }
.mc ul, .mc ol { margin: 0 0 .75em; padding-left: 1.5em; }
.mc li { margin: .25em 0; }
.mc li::marker { color: var(--muted); }
.mc a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.mc a:hover { text-decoration-color: currentColor; }
.mc blockquote { margin: 0 0 .75em; padding: 2px 14px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.mc img { max-width: 100%; border-radius: 8px; }
.mc hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.mc strong { font-weight: 600; }
.mc :not(pre) > code { font-family: var(--mono); font-size: .86em; background: var(--code); padding: 1px 5px; border-radius: 5px; color: var(--text); }
.mc.streaming:empty::after, .mc.streaming > :last-child:not(ul):not(ol):not(.code-block):not(.table-wrap)::after,
.mc.streaming > ul:last-child > li:last-child::after, .mc.streaming > ol:last-child > li:last-child::after { content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 4px; border-radius: 50%; background: var(--accent); vertical-align: 1px; animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .mc.streaming::after, .mc.streaming *::after { animation: none !important; } }
.code-block { margin: .6em 0 .9em; border-radius: 10px; overflow: hidden; background: #1E1D1B; border: 1px solid #2E2D2A; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; color: #A9A69C; font: 12px var(--mono); border-bottom: 1px solid #2E2D2A; }
.code-copy { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; color: #A9A69C; font: 12px var(--font); }
.code-copy:hover { background: #2E2D2A; color: #F2F0E8; }
.code-block pre { margin: 0; overflow-x: auto; }
.code-block pre code, .code-block pre code.hljs { display: block; padding: 12px 14px; font: 13px/1.55 var(--mono); color: #EDEBE3; background: none; white-space: pre; }
.table-wrap { overflow-x: auto; margin: .6em 0 .9em; }
.mc table { border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.mc th, .mc td { padding: 6px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.mc th { font-weight: 600; border-bottom-color: var(--line-strong); }

/* thinking, and the line that says what is going on */
.think { align-self: flex-start; max-width: 100%; margin: 12px 0 2px; color: var(--muted); font-size: 13.5px; }
.think summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 6px; margin-left: -6px; border-radius: 7px; user-select: none; }
.think summary:hover { background: var(--hover); color: var(--text); }
.think summary::-webkit-details-marker { display: none; }
.think summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-left: 2px; }
.think[open] summary::after { transform: rotate(45deg) translate(-1px, -1px); }
.think-text { margin: 6px 0 4px 2px; padding: 2px 0 2px 14px; border-left: 2px solid var(--line); white-space: pre-wrap; line-height: 1.65; max-height: 360px; overflow-y: auto; }
.tool, .working { align-self: flex-start; display: inline-flex; align-items: center; gap: 9px; margin: 12px 0 0; color: var(--muted); font-size: 13.5px; }
.pulse { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: breathe 1.2s ease-in-out infinite; }
.shimmer { background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 40%, var(--text) 50%, var(--muted) 60%, var(--muted) 100%); background-size: 240% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 2.2s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -40% 0; } }
@media (prefers-reduced-motion: reduce) { .pulse, .shimmer { animation: none; } .shimmer { color: var(--muted); background: none; } }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.sources { display: flex; gap: 6px; align-items: flex-start; margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: var(--hover); font-family: var(--font); font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.sources > .icon { margin-top: 1px; }

/* files in messages */
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.thumb-btn { border-radius: 10px; overflow: hidden; background: var(--code); min-width: 72px; min-height: 72px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.thumb-btn.loading { width: 180px; height: 120px; }
.thumb-btn.broken { padding: 0 12px; height: 72px; }
.thumb { display: block; max-width: 300px; max-height: 260px; object-fit: cover; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; font-family: var(--font); }
.chip { display: flex; align-items: center; gap: 10px; width: 280px; max-width: 100%; padding: 8px 10px; border-radius: 12px; background: var(--surface); color: var(--text); text-align: left; box-shadow: inset 0 0 0 1px var(--line); }
.ubub .chip { background: var(--bg); }
.chip:hover { box-shadow: inset 0 0 0 1px var(--line-strong); background: var(--hover); }
.chip.busy { opacity: .6; pointer-events: none; }
.chip > .icon { color: var(--muted); }
.fext { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 40px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-strong); font: 600 10px var(--mono); }
.chip-main { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.35; }
.chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; font-weight: 500; }
.chip-size { font-size: 12px; color: var(--muted); }

/* ---------- the composer: one rounded box, the message on top and its tools underneath ---------- */
.cbar { flex: none; position: relative; z-index: 2; padding: 4px 32px 10px; background: var(--bg); }
.cbar > * { max-width: 736px; margin-left: auto; margin-right: auto; }
.cbox { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 14px 12px 10px 16px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-md); border: 1px solid transparent; }
.cbox:focus-within { box-shadow: 0 2px 12px rgba(31, 30, 27, .09), 0 0 0 1px var(--line-strong); }
.cinput { width: 100%; min-height: 26px; max-height: 240px; padding: 0 2px; border: 0; outline: none; resize: none; background: transparent; color: var(--text); font-size: 15.5px; line-height: 1.6; }
.cinput::placeholder { color: var(--faint); }
.cinput:disabled { cursor: not-allowed; }
.cbox .pending, .cbox .queue { padding: 0; }
.ctools { display: flex; align-items: flex-end; gap: 4px; min-width: 0; }
.ctools > :not(.ctl-row) { margin-bottom: 0; }
.ctl-row { flex: 1 1 auto; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; scrollbar-width: none; }
.ctl-row::-webkit-scrollbar { display: none; }
.ctools-gap { flex: 1; min-width: 4px; }
.ctl-usage { flex: none; display: inline-flex; }
.cicon { flex: none; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line-strong); display: grid; place-items: center; color: var(--text-2); }
.cicon:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.cicon:disabled { opacity: .4; }
.ctl { flex: none; display: inline-flex; align-items: center; gap: 6px; max-width: 260px; height: 32px; padding: 0 10px; border-radius: 9px; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.ctl:hover, .ctl[aria-expanded="true"] { background: var(--hover); color: var(--text); }
.ctl > .icon { color: var(--muted); }
.ctl .av { width: 20px !important; height: 20px !important; }
.ctl-text { overflow: hidden; text-overflow: ellipsis; }
.ctl.on { background: var(--accent-soft); color: var(--accent-strong); }
.ctl.on > .icon { color: inherit; }
.ctl.ulink { color: var(--muted); font-size: 12.5px; padding: 0 8px; }
.ctl.proj-ctl { color: var(--text); font-weight: 500; border: 1px solid var(--line); }
.csend { flex: none; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.csend:hover:not(:disabled) { background: var(--accent-strong); }
.csend:disabled { background: var(--accent); color: var(--on-accent); opacity: .38; }
.csend.busy { opacity: .6; }
.csend.stop { background: var(--text); color: var(--bg); }
.csend.stop:hover:not(:disabled) { background: var(--text); opacity: .85; }
.cfoot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; padding: 8px 10px 0; color: var(--faint); font-size: 12px; }
.cfoot.center { justify-content: center; text-align: center; }
.cfoot-left { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
.cfoot-left .cfoot-path { flex: 1 1 auto; max-width: none; }
.home .cfoot { align-items: center; padding: 8px 2px 0; }
.cfoot .proj-ctl { height: 30px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 13px; }
.cfoot .proj-ctl:hover, .cfoot .proj-ctl[aria-expanded="true"] { border-color: var(--line-strong); background: var(--surface); }
.cfoot-path { min-width: 0; max-width: 60%; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcpt { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--muted); }
.ebars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.ebars i { width: 3px; border-radius: 1px; background: var(--line-strong); }
.ebars i:nth-child(1) { height: 4px; } .ebars i:nth-child(2) { height: 7px; } .ebars i:nth-child(3) { height: 10px; } .ebars i:nth-child(4) { height: 12px; }
.ebars i.on { background: var(--text-2); }
.pop .ebars { width: 18px; }
.uring { display: inline-flex; }
.uring-bg { stroke: var(--line); }
.uring-fg { stroke: var(--text-2); }
.uring.warn .uring-fg { stroke: #C2410C; }

/* files waiting to go out with the next message */
.pending { display: flex; flex-wrap: wrap; gap: 8px; }
.pitem { display: flex; align-items: center; gap: 8px; width: 230px; padding: 6px 6px 6px 8px; border-radius: 12px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.pitem.failed { box-shadow: inset 0 0 0 1.5px var(--danger); }
.pthumb { flex: none; width: 36px; height: 40px; border-radius: 8px; object-fit: cover; }
.pmain { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 3px; }
.pname { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psub { font-size: 12px; color: var(--muted); }
.px { flex: none; width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.px:hover { background: var(--hover); color: var(--text); }
.progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress-bar { display: block; height: 100%; background: var(--accent); transition: width .15s; }
.drop { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg) 86%, transparent); padding: 24px; }
.drop-box { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 56px; border: 2px dashed var(--accent); border-radius: 18px; background: var(--surface); color: var(--accent-strong); pointer-events: none; }
.drop-box span:last-child { color: var(--muted); font-size: 13px; }
.cbox .drop { border-radius: 20px; padding: 8px; }
.cbox .drop-box { padding: 14px 28px; }

/* ---------- a new conversation / a new task: the greeting, the box, and what to pick ---------- */
.home { flex: 1; min-height: 0; overflow-y: auto; display: flex; }
.home-inner { width: 100%; max-width: 760px; margin: auto; padding: 32px 24px 12vh; display: flex; flex-direction: column; gap: 16px; }
.greet { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 14px; }
.greet img { width: 34px; height: 34px; border-radius: 10px; }
.greet-text { font-family: var(--serif); font-size: 36px; font-weight: 400; letter-spacing: -.015em; line-height: 1.25; color: var(--text); text-align: center; }
.home .cbox { padding: 16px 14px 12px 18px; border-radius: 22px; }
.home .cinput { min-height: 56px; }
.home-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.hchip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px 0 8px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text-2); font-size: 13.5px; }
.hchip:hover:not(.on) { background: var(--hover); color: var(--text); border-color: var(--line-strong); }
.hchip.on { background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow); font-weight: 500; }
.hchip > .icon { color: var(--muted); }
.hchip .state::before { width: 6px; height: 6px; }
.home-hint { color: var(--faint); font-size: 12.5px; text-align: center; }
.home-hint.warn { color: var(--warn); }

/* ---------- project mode: the list ---------- */
.spin { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; color: var(--run); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; border-right-color: currentColor; opacity: .7; } }
.etile { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 700; font-family: var(--font); }
.etile.off { background: #9C9A92; }
.proj { position: relative; display: flex; align-items: center; gap: 2px; margin-top: 2px; }
.proj-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 8px; border-radius: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; text-align: left; }
.proj-main:hover { background: var(--hover); color: var(--text); }
.proj-main > .icon { color: var(--muted); }
.proj-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-main .state, .proj-main .tag { flex: none; font-weight: 400; }
.proj-count { margin-left: auto; color: var(--faint); font-size: 12px; font-weight: 400; }
.proj-fold { flex: none; display: inline-flex; color: var(--faint); }
.proj:hover .proj-fold { visibility: hidden; }
.proj-add { position: absolute; right: 2px; top: 2px; width: 28px; height: 28px; border-radius: 7px; opacity: 0; background: var(--side); }
.proj:hover .proj-add, .proj-add:focus-visible { opacity: 1; }
.proj:hover .proj-count { visibility: hidden; }
.proj-empty { padding: 2px 10px 8px 31px; color: var(--faint); font-size: 12.5px; }
.proj-more { display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 10px 6px 31px; border-radius: 8px; color: var(--muted); font-size: 12.5px; text-align: left; }
.proj-more:hover { color: var(--text); background: var(--hover); }
.proj-more.top { padding-left: 10px; margin-top: 6px; }
.trow { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 5px 10px 5px 12px; border-radius: 8px; text-align: left; color: var(--text-2); font-size: 13.5px; }
.trow:hover { background: var(--hover); color: var(--text); }
.trow.on { background: var(--active); color: var(--text); }
.trow-mark { flex: none; width: 13px; display: inline-grid; place-items: center; color: var(--muted); }
.trow-mark i { width: 7px; height: 7px; border-radius: 50%; background: var(--wait); }
.trow-mark.fresh i { background: var(--accent); }
.trow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.trow-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 20px; }
.trow-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow-meta { flex: none; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.trow-meta.run { color: var(--run); }
.trow-meta.wait { color: var(--wait); font-weight: 600; }
.trow-engine { flex: none; padding: 0 5px; border-radius: 5px; background: var(--active); color: var(--muted); font-size: 10.5px; line-height: 17px; }
.trow.archived .trow-title { color: var(--muted); }
.pinmark { display: inline-flex; margin-right: 4px; color: var(--muted); vertical-align: -1px; }
.envbtn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-align: left; }
.envbtn:hover, .envbtn[aria-expanded="true"] { border-color: var(--line-strong); }
.envbtn > .icon:last-child { color: var(--muted); }
.env-tile { position: relative; flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--active); color: var(--text-2); display: grid; place-items: center; }
.env-dot { position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; background: #9C9A92; border: 2px solid var(--surface); }
.env-dot.on { background: #4D9A55; }
.env-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.env-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- project mode: a session ---------- */
.ctitle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px 10px; padding-left: 6px; }
.bar .ctitle-name { flex: 0 1 auto; min-width: 0; font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctitle-chips { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.cchip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 7px; background: var(--hover); color: var(--muted); font-size: 12px; white-space: nowrap; }
.cchip .etile { width: 15px; height: 15px; border-radius: 4px; font-size: 9px; }
.cchip.mono { font-family: var(--mono); }
.envpill { display: none; }
.hstate { flex: none; display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; color: var(--run); font-size: 12.5px; white-space: nowrap; }
.hstate.wait { color: var(--wait); }
.hstate.wait i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.hbtn { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; margin-left: 2px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-size: 13px; }
.hbtn:hover { background: var(--hover); color: var(--text); }
.hbtn.on { background: var(--active); color: var(--text); font-weight: 600; }
.hbtn > .icon { color: var(--muted); }
.code-body { position: relative; flex: 1; min-height: 0; display: flex; }
.code-main { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* what the agent did: one quiet line per tool call, details on demand */
.step { align-self: stretch; margin: 2px 0 0 -8px; border-radius: 10px; color: var(--muted); font-size: 13.5px; }
.step summary { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 8px; border-radius: 8px; cursor: pointer; list-style: none; user-select: none; }
.step summary::-webkit-details-marker { display: none; }
.step summary:hover { background: var(--hover); color: var(--text); }
.step summary > .icon { color: var(--faint); }
.step-label { flex: none; color: var(--text-2); font-weight: 500; }
.step-target { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 12.5px var(--mono); color: var(--muted); }
.step-target.plain { font: inherit; font-size: 13px; }
.step-state { flex: none; margin-left: auto; padding-left: 6px; display: inline-flex; align-items: center; font-size: 12px; color: var(--muted); }
.step.error .step-state { color: var(--danger); }
.step-state .spin { width: 11px; height: 11px; }
.step[open] { margin: 8px 0 6px -8px; border: 1px solid var(--line); background: var(--surface); }
.step[open] summary { border-radius: 10px 10px 0 0; }
.step-body { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.step-pre { margin: 0; max-height: 320px; overflow: auto; padding: 10px 12px; border-radius: 8px; background: var(--bg); color: var(--text); font: 12.5px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: inset 0 0 0 1px var(--line); }
.step-pre.cmd { background: #1E1D1B; color: #EDEBE3; box-shadow: none; }
.step-pre.err { color: var(--danger); }
.step-pre .del { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); display: block; }
.step-pre .add { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); display: block; }
.step-pre .hunk { color: var(--link); }
.step-note { color: var(--muted); font-size: 12.5px; }
.step-count { flex: none; display: inline-flex; gap: 6px; font: 12px var(--mono); }
.step-count .add { color: var(--ok); }
.step-count .del { color: var(--danger); }
.step.plan-done.rejected .step-target { color: var(--danger); }
.todos { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.todos li { display: flex; align-items: baseline; gap: 8px; }
.todo-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 4px; box-shadow: inset 0 0 0 1.5px var(--line-strong); font-size: 11px; line-height: 1; transform: translateY(2px); }
.todos li.completed { color: var(--muted); }
.todos li.completed .todo-mark { background: var(--ok); box-shadow: none; color: #fff; }
.todos li.in_progress { color: var(--text); font-weight: 600; }
.todo-card { align-self: stretch; display: flex; flex-direction: column; gap: 8px; margin: 12px 0 6px; padding: 12px 16px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-md); color: var(--text); font-size: 14px; }
.todo-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.todo-row { display: flex; align-items: center; gap: 10px; }
.todo-row > .icon, .todo-row > .spin, .todo-dot { flex: none; }
.todo-row.completed { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.todo-row.completed > .icon { color: var(--ok); }
.todo-row.in_progress { font-weight: 500; }
.todo-dot { width: 14px; height: 14px; margin: 0 1px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); }

/* the agent asks before it changes something, asks a question, or shows its plan */
.ask { align-self: stretch; max-width: 680px; margin: 12px 0 6px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-md), inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.ask-title { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; }
.ask-title .icon { color: var(--accent); }
.ask-desc { color: var(--text-2); font-size: 13.5px; overflow-wrap: anywhere; }
.ask-desc code, .askline code { font: 12.5px var(--mono); }
.ask-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-actions .pbtn:not(.ghost) { background: var(--accent); color: var(--on-accent); }
.askline { align-self: flex-start; max-width: 100%; display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.askline > span { flex: none; }
.askline code { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.askline.allowed > .icon { color: var(--ok); }
.askline.denied { color: var(--danger); }
.failbox { align-self: stretch; margin: 12px 0 6px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.failbox strong { font-weight: 600; }
.failbox pre { margin: 0; max-height: 200px; overflow: auto; font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.ask.question, .ask.plan { max-width: 720px; }
.q-block { display: flex; flex-direction: column; gap: 8px; }
.q-block + .q-block { padding-top: 10px; border-top: 1px solid var(--line); }
.q-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; font-size: 14.5px; }
.q-multi { color: var(--muted); font-size: 12.5px; }
.q-opts { display: flex; flex-direction: column; gap: 6px; }
.q-opt { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; text-align: left; box-shadow: inset 0 0 0 1px var(--line-strong); }
.q-opt:hover:not(:disabled) { background: var(--hover); }
.q-opt.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.q-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.q-mark.box { border-radius: 4px; }
.q-opt.on .q-mark { box-shadow: inset 0 0 0 5px var(--accent); }
.q-opt.on .q-mark.box { background: var(--accent); box-shadow: none; }
.q-opt.on .q-mark.box::after { content: "✓"; color: #fff; font-size: 11px; line-height: 1; }
.q-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.q-text strong { font-weight: 600; font-size: 14px; }
.q-text span { color: var(--text-2); font-size: 13px; line-height: 1.5; }
.q-other, .commit-msg { width: 100%; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); outline: none; font-size: 14px; line-height: 1.5; }
.q-other { height: 38px; padding-top: 0; padding-bottom: 0; }
.q-other:focus, .commit-msg:focus { border-color: var(--accent); }
.commit-msg { resize: vertical; min-height: 40px; }
.qa { align-self: flex-start; max-width: 100%; margin: 6px 0 0; display: flex; flex-direction: column; gap: 3px; color: var(--text-2); font-size: 13px; }
.qa-title { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.qa.answered .qa-title > .icon { color: var(--ok); }
.qa-row { display: flex; flex-wrap: wrap; gap: 2px 8px; }
.qa-q { color: var(--muted); }
.qa-a { color: var(--text); font-weight: 600; }
.plan-body { max-height: 420px; overflow-y: auto; padding: 12px 14px; border-radius: 10px; background: var(--bg); font-size: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.step-body .plan-body { max-height: none; }
.donel { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; margin: 14px 0 2px; color: var(--faint); font-size: 12px; }
.donel > .icon { color: var(--ok); }
.donel.cancelled > .icon { color: var(--muted); }

/* messages waiting for the turn to end */
.queue { display: flex; flex-direction: column; gap: 4px; }
.queue-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--muted); }
.qitem { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; border-radius: 10px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); font-size: 13.5px; }
.qitem > .icon { color: var(--muted); }
.qtext { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qtext .tag { margin-right: 6px; }
.qfiles { color: var(--muted); }

/* a session's side panel: what changed in the project, and its files */
.cside-host { flex: none; width: min(44%, 500px); min-width: 320px; min-height: 0; display: flex; background: var(--surface); border-left: 1px solid var(--line); }
.cside { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.cside-head { flex: none; display: flex; align-items: center; gap: 2px; height: 52px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); }
.cside-tabs { flex: 1; display: flex; gap: 4px; }
.cside-tab { height: 30px; padding: 0 12px; border-radius: 8px; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.cside-tab:hover { color: var(--text); background: var(--hover); }
.cside-tab.on { background: var(--active); color: var(--text); font-weight: 600; }
.cside-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 24px; display: flex; flex-direction: column; gap: 4px; }
.cside-body > * { flex: none; }
.cside-note { padding: 4px 2px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.cside-note.bad { color: var(--danger); }
.cside-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 2px 2px 6px; color: var(--text-2); font-size: 13px; }
.cside-meta > .icon { color: var(--muted); }
.cside-meta code { min-width: 0; font: 12.5px var(--mono); overflow-wrap: anywhere; }
.cside-meta .crumb { flex: 1; }
.cside-meta .ib { width: 32px; height: 32px; margin-left: auto; }
.crumb-sep { color: var(--muted); }
.cside-actions { padding-top: 8px; }
.chg, .fentry { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 5px 8px; border-radius: 8px; text-align: left; font-size: 13.5px; }
.chg:hover, .chg.on, .fentry:hover { background: var(--hover); }
.chg-mark { flex: none; min-width: 22px; padding: 0 4px; border-radius: 5px; font-size: 11.5px; font-weight: 600; line-height: 20px; text-align: center; }
.chg-mark.mod { background: var(--warn-soft); color: var(--warn); }
.chg-mark.add { background: var(--ok-soft); color: var(--ok); }
.chg-mark.del { background: var(--danger-soft); color: var(--danger); }
.chg-path { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 12.5px var(--mono); }
.chg-dir { color: var(--muted); }
.chg-num { flex: none; font: 12px var(--mono); }
.chg-num .add { color: var(--ok); }
.chg-num .del { color: var(--danger); }
.chg-diff { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.chg-diff .step-pre, .step-pre.file-text { max-height: 460px; white-space: pre; overflow-wrap: normal; }
.step-pre.file-text { max-height: none; overflow-y: visible; }
.commit-box { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.fentry > .icon { color: var(--muted); }
.fname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fsize { flex: none; color: var(--muted); font-size: 12px; }
.cside-img { align-self: flex-start; max-width: 100%; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.cside-img img { display: block; max-width: 100%; max-height: 60vh; }
@media (max-width: 1180px) {
  .cside-host { position: absolute; top: 0; right: 0; bottom: 0; z-index: 6; width: min(100%, 480px); min-width: 0; box-shadow: var(--shadow-lg); }
}

/* choices that belong to a button: a panel next to it, or a sheet from the bottom on a phone */
.pop { position: fixed; z-index: 55; max-height: min(70vh, 560px); overflow-y: auto; padding: 6px; border-radius: 14px; background: var(--menu); color: var(--text); box-shadow: var(--shadow-lg); }
.pop-title { padding: 8px 10px 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.pop-group { display: flex; align-items: center; gap: 8px; padding: 10px 10px 2px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.pop-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; }
.pop-group-name { flex: 1; min-width: 0; }
.pop-group-note { color: var(--muted); font-weight: 400; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 6px 10px; border-radius: 9px; text-align: left; }
.pop-item:hover:not(:disabled), .pop-item:focus-visible { background: var(--hover); outline: none; }
.pop-item:disabled { opacity: .55; cursor: default; }
.pop-item.on { background: var(--hover); }
.pop-item > .icon:last-child { color: var(--accent); }
.pop-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.pop-label { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop-hint { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.pop-search { position: sticky; top: -6px; z-index: 1; margin: -6px -6px 4px; padding: 8px 8px 6px; background: var(--menu); border-bottom: 1px solid var(--line); }
.pop-search input { width: 100%; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--bg); outline: none; font-size: 14px; }
.pop-empty { padding: 14px 10px; color: var(--muted); font-size: 13px; text-align: center; }
.pop-layer { position: fixed; inset: 0; z-index: 55; display: flex; flex-direction: column; justify-content: flex-end; }
.pop-scrim { position: absolute; inset: 0; background: var(--scrim); }
.pop.sheet { position: relative; max-height: 82vh; padding: 8px 10px calc(16px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; }
.pop-grab { width: 38px; height: 5px; margin: 0 auto 6px; border-radius: 3px; background: var(--line-strong); }
.pop.sheet .pop-title { padding: 4px 10px 8px; color: var(--text); font-size: 15px; font-weight: 600; }
.pop.sheet .pop-item { min-height: 50px; }
.pop.sheet .pop-search { top: -8px; margin: -8px -10px 4px; }
.usage { display: flex; flex-direction: column; gap: 12px; padding: 4px 10px 8px; }
.usage-who { color: var(--muted); font-size: 12.5px; }
.urow { display: flex; flex-direction: column; gap: 6px; }
.urow-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.urow-head strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.ubar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ubar i { display: block; height: 100%; border-radius: 3px; background: var(--text-2); }
.ubar.warn i { background: #C2410C; }
.urow-note { color: var(--muted); font-size: 12px; }
.usage-note { color: var(--text-2); font-size: 13px; line-height: 1.6; }
.usage .link { align-self: flex-start; font-size: 13px; }

/* Hermes asks before a command: the card in the conversation, and the record under the reply */
.ask.hermes-ask .step-pre.cmd { max-height: 220px; }
.approvals { flex-direction: column; gap: 3px; }
.appr { display: flex; align-items: center; gap: 6px; min-width: 0; }
.appr code { min-width: 0; font: 12px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appr.allowed > .icon { color: var(--ok); }
.appr.denied { color: var(--danger); }

/* ---------- sign-in ---------- */
.login { height: 100%; overflow-y: auto; background: var(--bg); display: flex; flex-direction: column; }
.login > .bar { background: transparent; justify-content: center; height: auto; padding: 48px 16px 0; }
.login > .bar h1 { flex: none; font-family: var(--serif); font-size: 32px; font-weight: 400; letter-spacing: -.015em; }
.login-body { width: 100%; max-width: 420px; margin: 0 auto; padding: 22px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.login-logo { align-self: center; width: 64px; height: 64px; border-radius: 18px; overflow: hidden; display: flex; order: -1; }
.login-logo img { width: 100%; height: 100%; }
.login-sub { text-align: center; color: var(--muted); line-height: 1.7; font-size: 14px; }
.group { background: var(--surface); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-md); }
.grow { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.grow:last-child { border-bottom: 0; }
.grow label { flex: none; width: 72px; font-size: 14.5px; color: var(--text-2); }
.grow input { flex: 1; min-width: 0; height: 50px; border: 0; background: transparent; outline: none; font-size: 15px; }
.login-body .pbtn.block { height: 44px; background: var(--accent); color: var(--on-accent); border-radius: 12px; }
.login-foot { text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 10px 14px; border-radius: 10px; font-size: 14px; }

/* ---------- dialogs and forms ---------- */
.dialog { width: min(92vw, 460px); max-height: 88vh; padding: 22px 22px 16px; border: 0; border-radius: 16px; background: var(--menu); color: var(--text); box-shadow: var(--shadow-lg); overflow-y: auto; }
.dialog.wide { width: min(94vw, 600px); }
.dialog::backdrop, .lightbox::backdrop { background: var(--scrim); }
.dialog h2 { font-family: var(--serif); font-size: 21px; font-weight: 500; margin-bottom: 10px; }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog form h2 { margin-bottom: 0; }
.dialog-text { color: var(--text-2); line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog form .dialog-actions { margin-top: 2px; }
.fields { display: flex; flex-direction: column; }
.field { padding: 8px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field-row { display: flex; align-items: center; gap: 12px; }
.field-row > label { flex: none; width: 104px; font-size: 14px; color: var(--text-2); }
.field.stack .field-row { flex-direction: column; align-items: stretch; gap: 6px; }
.field.stack .field-row > label { width: auto; }
.field input:not([type="checkbox"]), .field select { flex: 1; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); outline: none; }
.field input:not([type="checkbox"]):focus, .field select:focus { border-color: var(--accent); }
.field select { cursor: pointer; }
.field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); resize: vertical; line-height: 1.5; outline: none; }
.field textarea:focus { border-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.check.small { font-size: 12.5px; gap: 5px; color: var(--muted); }
.checklist { display: flex; flex-direction: column; gap: 9px; max-height: 190px; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; }

/* ---------- overlays ---------- */
#toasts { position: fixed; z-index: 60; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { max-width: min(92vw, 460px); padding: 10px 18px; border-radius: 12px; background: var(--toast); color: var(--bg); font-size: 14px; box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(6px); }
.menu { position: fixed; z-index: 50; min-width: 200px; padding: 6px; border-radius: 12px; background: var(--menu); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.menu-head { padding: 8px 10px 8px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-wrap: anywhere; }
.menu-item { padding: 8px 10px; border-radius: 8px; text-align: left; font-size: 14px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item.danger { color: var(--danger); }
.lightbox { max-width: 96vw; max-height: 96vh; padding: 0; border: 0; background: transparent; }
.lightbox img { display: block; max-width: 96vw; max-height: calc(96vh - 56px); border-radius: 10px; cursor: zoom-out; }
.lightbox-bar { display: flex; align-items: center; gap: 8px; padding-top: 10px; }
.lightbox-name { flex: 1; min-width: 0; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- admin console ---------- */
.admin { height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.admin > .bar { border-bottom: 0; }
.admin > .bar h1 { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.tabs { flex: none; display: flex; gap: 2px; padding: 0 12px; background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { position: relative; padding: 10px 14px; color: var(--muted); font-weight: 500; font-size: 14px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }
.admin-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.admin-body { max-width: 1080px; margin: 0 auto; padding: 18px 16px 56px; display: flex; flex-direction: column; gap: 14px; }
.admin-empty { padding: 40px 16px; color: var(--muted); text-align: center; }
.stats { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; padding: 0 4px; }
.note { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 0 4px; }
.toolbar p { color: var(--muted); font-size: 14px; }
.toolbar .tools { display: flex; align-items: center; gap: 8px; }
.table-scroll { overflow-x: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-md); }
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid thead th { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.grid tbody tr:last-child > * { border-bottom: 0; }
.grid tr.off { color: var(--muted); }
.grid .num { font-variant-numeric: tabular-nums; }
.grid .actions { width: 1%; padding: 4px 8px; }
.grid td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 200px; color: var(--text-2); }
.cell-user { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.rowcard { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.rowcard:last-child { border-bottom: 0; }
.setup-mark { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--bg); color: var(--muted); font-size: 14px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.setup-step.done .setup-mark { background: var(--ok); color: #fff; box-shadow: none; }
.setup-step .rowcard-main { gap: 6px; }
.setup-step .rowcard-actions { justify-content: flex-start; margin-top: 4px; }
.setup-step .codebox { margin-top: 6px; }
.rowcard-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rowcard-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 15px; }
.rowcard-title strong { font-weight: 600; }
.rowcard-desc { color: var(--text-2); font-size: 14px; }
.rowcard-meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.rowcard-actions { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.doc-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.doc { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.doc .x { color: var(--muted); width: 24px; height: 24px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.doc .x:hover { background: var(--hover); color: var(--danger); }
.matrix th, .matrix td { text-align: center; }
.matrix .sticky { position: sticky; left: 0; z-index: 1; text-align: left; background: var(--surface); font-weight: 500; }
.bot-col { min-width: 112px; }
.bot-col-head { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 4px; }
.bot-col-name { max-width: 110px; color: var(--text); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grant input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.grant input:disabled { cursor: default; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 96px; padding: 14px 16px 6px; }
.bars .b { flex: 1; min-width: 4px; max-width: 28px; border-radius: 3px 3px 0 0; background: var(--accent); opacity: .85; }
.bars .b:hover { opacity: 1; }
.bars-x { display: flex; justify-content: space-between; padding: 0 16px 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; padding: 14px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; }
.inline-form input { width: 120px; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); outline: none; }
.inline-form input:focus { border-color: var(--accent); }
/* 系统 → 版本与升级 */
.upgrade-offer { border-top: 1px solid var(--line); }
.inline-form .check input { width: 16px; height: 16px; padding: 0; border: 0; }
.upgrade-status { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 14px; }
.upgrade-status .note { white-space: pre-wrap; overflow-wrap: anywhere; }
.upgrade-now { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.upgrade-steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.upgrade-steps li { counter-increment: step; padding: 3px 10px; border-radius: 999px; background: var(--active); color: var(--muted); font-size: 12.5px; }
.upgrade-steps li::before { content: counter(step) ". "; }
.upgrade-steps li.done { background: var(--ok-soft); color: var(--ok); }
.upgrade-steps li.now { background: var(--accent); color: var(--on-accent); }
.codebox { margin: 0; padding: 10px 12px; border-radius: 9px; background: #1E1D1B; color: #EDEBE3; font: 12.5px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
.steps { margin: 0; padding: 14px 16px 14px 36px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--text-2); }
.steps li::marker { color: var(--accent-strong); font-weight: 600; }
.steps .codebox { margin-top: 6px; }
.dirpick { display: flex; flex-direction: column; gap: 8px; }
.dirpath { display: flex; align-items: center; gap: 8px; font: 12.5px var(--mono); color: var(--text-2); overflow-wrap: anywhere; }
.dirlist { max-height: 240px; overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 9px; }
.dirrow { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--line); }
.dirrow:last-child { border-bottom: 0; }
.dirrow:hover { background: var(--hover); }
.dirrow > .icon { color: var(--muted); }
.dirrow .tag { margin-left: auto; }
.radios { display: flex; flex-direction: column; gap: 4px; }
.radio { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.radio:hover { background: var(--hover); }
.radio input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--accent); }
.radio input:disabled + span { opacity: .5; }
.radio strong { display: block; font-weight: 600; font-size: 14.5px; }
.radio small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.av.proj-av { border-radius: 28%; }
.tabbar { display: none; }

/* ---------- narrow windows: one pane at a time, as on the phone ---------- */
@media (max-width: 760px) {
  .shell, .shell.side-off { grid-template-columns: minmax(0, 1fr); }
  .shell .main { display: none; }
  .shell.show-main .side { display: none; }
  .shell.show-main .main { display: flex; }
  .shell.side-off .side { visibility: visible; }
  .side-open, .side-close { display: none !important; }
  .only-narrow { display: inline-flex; }
  .wide-only { display: none !important; }
  .side { border-right: 0; }
  .msgs-inner { padding: 0 16px; }
  .ubub { max-width: 88%; }
  .cbar { padding: 4px 10px 10px; }
  .cbox { padding: 12px 10px 8px 14px; border-radius: 18px; }
  .cfoot-path { max-width: 100%; }
  .cfoot.center { display: none; }
  .home-inner { padding: 20px 14px 32px; margin-top: 0; }
  .greet { margin: 18px 0 6px; }
  .greet-text { font-size: 27px; }
  .greet img { width: 28px; height: 28px; }
  .ctitle { flex-direction: column; align-items: flex-start; gap: 2px; }
  .envpill { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 20px; padding: 0 8px 0 7px; border-radius: 10px; background: var(--hover); color: var(--text-2); font-size: 11.5px; }
  .envpill > span:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .envpill .env-dot { position: static; width: 7px; height: 7px; border: 0; }
  .hbtn { width: 34px; padding: 0; justify-content: center; }
  .hbtn-text { display: none; }
  .hstate { display: none; }
  .ctools { align-items: center; }
  .ctl-row { flex-wrap: nowrap; overflow-x: auto; }
  .ctl { background: var(--hover); }
  .ctl.on { background: var(--accent-soft); }
  .cside-host { width: 100%; }
  .thumb { max-width: 220px; }
  .pitem { width: 100%; }
  .step, .step[open] { margin-left: -6px; }
  .proj-add { opacity: 1; background: transparent; }
  .proj:hover .proj-count { visibility: visible; }
  .acts { opacity: 1; }
  .rowcard { flex-wrap: wrap; }
  .rowcard-actions { width: 100%; }
  .field-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .field-row > label { width: auto; }
  /* the modes move from the top of the list to a tab bar at the bottom, as in the phone apps */
  .side .modes, .side .acct { display: none; }
  .tabbar { flex: none; display: grid; grid-template-columns: repeat(var(--tabs, 3), minmax(0, 1fr)); padding: 6px 0 calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--side); }
  .tb { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11.5px; }
  .tb-icon { position: relative; width: 56px; height: 30px; border-radius: 15px; display: grid; place-items: center; }
  .tb.on { color: var(--text); font-weight: 600; }
  .tb.on .tb-icon { background: var(--active); }
  .tb-icon .badge { position: absolute; top: 3px; right: 13px; }
  .list { padding-bottom: 12px; }
  .crow { min-height: 44px; }
  .trow { min-height: 40px; }
}

/* ---------- project mode on a phone, as in the Claude app: the page is the task, the list is a drawer over it ----------
   The drawer holds the 聊天/项目 switch, 新任务 and search, the projects (all folded; tapping one unfolds it and folds the
   others) with their tasks, the server switcher and the account. The tab bar belongs to chat mode only. */
.m-scrim { display: none; }
@media (max-width: 760px) {
  .shell.mode-code .main, .shell.mode-code.show-main .main { display: flex; }
  .shell.mode-code .side, .shell.mode-code.show-main .side {
    display: flex; position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(86vw, 340px);
    padding-top: env(safe-area-inset-top); border-right: 0; border-radius: 0 18px 18px 0;
    transform: translateX(-102%); visibility: hidden; transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .26s;
  }
  .shell.mode-code.drawer-open .side { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.2, .8, .2, 1); box-shadow: 8px 0 40px rgba(0, 0, 0, .18); }
  .shell.mode-code .m-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(20, 16, 12, .36); opacity: 0; pointer-events: none; transition: opacity .22s; }
  .shell.mode-code.drawer-open .m-scrim { opacity: 1; pointer-events: auto; }
  .shell.mode-code .tabbar { display: none; }
  .shell.mode-code .side .modes { display: flex; margin-top: 2px; }
  .shell.mode-code .side .acct { display: flex; margin-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .shell.mode-code .side-top { height: 56px; }
  .shell.mode-code .nrow { min-height: 42px; font-size: 15px; }
  .shell.mode-code .searchbox input { height: 42px; font-size: 15px; }
  /* a project: one big row to tap; its tasks indented under it when unfolded */
  .shell.mode-code .proj { margin-top: 1px; }
  .shell.mode-code .proj-main { height: 46px; padding: 0 6px 0 10px; gap: 10px; border-radius: 10px; font-size: 15px; }
  .shell.mode-code .proj.open > .proj-main { color: var(--text); font-weight: 600; }
  .shell.mode-code .proj.here > .proj-main { color: var(--text); }
  .shell.mode-code .proj.here:not(.open) > .proj-main { background: var(--active); }
  .shell.mode-code .proj-count { margin-left: auto; font-size: 13px; }
  .shell.mode-code .proj-fold { order: 9; margin-left: 2px; }
  .shell.mode-code .proj:hover .proj-fold, .shell.mode-code .proj:hover .proj-count { visibility: visible; }
  .shell.mode-code .proj-add { position: static; flex: none; width: 40px; height: 40px; opacity: 1; background: transparent; color: var(--muted); }
  .shell.mode-code .proj.open + .trow, .shell.mode-code .trow + .trow { margin-top: 1px; }
  .shell.mode-code .trow { min-height: 46px; padding: 6px 10px 6px 22px; font-size: 14.5px; }
  .shell.mode-code .proj-more { min-height: 40px; padding-left: 40px; font-size: 13.5px; }
  .shell.mode-code .proj-more.top { padding-left: 10px; }
  .shell.mode-code .proj-empty { padding-left: 40px; }
  .shell.mode-code .side-foot { padding: 6px 10px 0; }
  .shell.mode-code .bar { height: 54px; padding-left: 6px; }
  .shell.mode-code .bar .ctitle { padding-left: 2px; }
}
@media (max-width: 760px) and (prefers-color-scheme: dark) {
  .shell.mode-code .m-scrim { background: rgba(0, 0, 0, .55); }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .shell.mode-code .side, .shell.mode-code.drawer-open .side, .shell.mode-code .m-scrim { transition: none; }
}

/* ---------- under the composer, as in the Claude app: where it works on the left; model, mode, usage on the right ---------- */
.cunder { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; min-height: 34px; padding: 6px 2px 0; }
.cunder-left { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
.cunder-right { flex: none; display: flex; align-items: center; gap: 2px; }
.cunder-path { min-width: 0; color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home .cunder-path { font-family: var(--mono); }
.uctl { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; border-radius: 8px; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.uctl:hover, .uctl[aria-expanded="true"] { background: var(--active); color: var(--text); }
.uctl > .icon { color: var(--muted); }
.uctl-sub { color: var(--muted); }
.uctl-tag { padding: 0 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-strong); font-size: 11px; line-height: 18px; }
.uctl.on { background: var(--accent-soft); color: var(--accent-strong); }
.uctl.ring { padding: 0 7px; }
.pop-div { height: 1px; margin: 5px 4px; background: var(--line); }
.pop-section { padding: 8px 10px 2px; color: var(--muted); font-size: 12px; font-weight: 500; }
.pop-key { flex: none; min-width: 16px; color: var(--faint); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.pop-value { flex: none; color: var(--muted); font-size: 13px; }
.pop-item.sub > .icon:last-child { color: var(--muted); }
.pop-tag { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 5px; background: var(--active); color: var(--text-2); font-size: 11px; font-weight: 500; line-height: 18px; vertical-align: 1px; }
.pop-back { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 10px 6px; border-radius: 8px; color: var(--muted); font-size: 12.5px; font-weight: 500; text-align: left; }
.pop-back:hover { background: var(--hover); color: var(--text); }
.usage { gap: 14px; padding: 8px 10px 10px; }
.usage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.usage-all { display: inline-flex; align-items: center; gap: 2px; color: var(--text); font-size: 13px; font-weight: 500; }
.usage-all:hover { text-decoration: underline; }
.urow-right { display: inline-flex; align-items: baseline; gap: 10px; color: var(--muted); font-size: 12.5px; }
.urow-right strong { color: var(--text-2); font-weight: 500; }
.ubar { height: 5px; background: var(--active); }
.ubar i { background: #3B82F6; }
.ubar.warn i { background: #C2410C; }
.usage-who { color: var(--faint); font-size: 12px; }
@media (max-width: 760px) {
  .cunder { flex-wrap: wrap; }
  .cunder-right { margin-left: auto; }
}

/* =====================================================================================================================
   Chat mode: Telegram's look. A white list panel floating on a green doodle wallpaper, big avatars with time and
   unread count, a round pencil for a new chat; a floating header, bubbles with tails and the time inside, and a
   pill-shaped composer with a round send button. Project mode keeps the Claude look above.
   ===================================================================================================================== */
:root {
  --tg-accent: #3390EC; --tg-accent-2: #2A7FD4; --tg-sel: #3390EC; --tg-side: #FFFFFF; --tg-text: #000000; --tg-muted: #707579; --tg-hover: #F4F4F5; --tg-line: #E7E8EA;
  --tg-in: #FFFFFF; --tg-out: #EEFFDE; --tg-in-meta: #A1AAB3; --tg-out-meta: #4FAE4E; --tg-link: #3390EC; --tg-chip: rgba(0, 0, 0, .05);
  --tg-wall: linear-gradient(140deg, #D9E3B9 0%, #9DC394 32%, #C9D48D 62%, #86B784 100%); --tg-doodle: #2E5A21; --tg-doodle-op: .11;
  --tg-pill: rgba(74, 104, 56, .38); --tg-shadow: 0 1px 2px rgba(16, 35, 47, .15);
  --tg-callout: #EAF3FD; --tg-rule: #DCE1E6; --tg-th: #F1F5F9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --tg-accent: #5EA4EE; --tg-accent-2: #4C93DE; --tg-sel: #2B5278; --tg-side: #17212B; --tg-text: #F5F5F5; --tg-muted: #7F91A4; --tg-hover: #202B36; --tg-line: #0E1621;
    --tg-in: #182533; --tg-out: #2B5278; --tg-in-meta: #6D7F8F; --tg-out-meta: #7DA8D3; --tg-link: #71B6F7; --tg-chip: rgba(255, 255, 255, .06);
    --tg-wall: linear-gradient(140deg, #0E1621 0%, #13202C 50%, #0E1621 100%); --tg-doodle: #9DB6CC; --tg-doodle-op: .05;
    --tg-pill: rgba(23, 33, 43, .72); --tg-shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --tg-callout: rgba(94, 164, 238, .13); --tg-rule: #2B3A49; --tg-th: rgba(255, 255, 255, .05);
  }
}
/* the parts of the sidebar that belong to one look only */
.tg-top, .fab { display: none; }
.shell.chat-mode .side-top, .shell.chat-mode .side-nav, .shell.chat-mode .acct, .shell.chat-mode .side-foot, .shell.chat-mode .side-open { display: none !important; }
.shell.chat-mode .tg-top { display: flex; }
.shell.chat-mode .fab { display: flex; }
.shell.chat-mode.side-off { grid-template-columns: 380px minmax(0, 1fr); }
.shell.chat-mode.side-off .side { visibility: visible; }

.shell.chat-mode { position: relative; grid-template-columns: 380px minmax(0, 1fr); background: var(--tg-wall); color: var(--tg-text); }
.shell.chat-mode::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: var(--tg-doodle); opacity: var(--tg-doodle-op);
  -webkit-mask-image: url(/web/wallpapers/doodle.svg); mask-image: url(/web/wallpapers/doodle.svg); -webkit-mask-size: 210px 210px; mask-size: 210px 210px; }
.shell.chat-mode > .side, .shell.chat-mode > .main { position: relative; z-index: 1; }
.shell.chat-mode .side { margin: 10px 0 10px 10px; border: 0; border-radius: 16px; background: var(--tg-side); box-shadow: var(--tg-shadow); }
.shell.chat-mode .main { background: transparent; }

/* the list */
.tg-top { flex: none; align-items: center; gap: 8px; padding: 10px 12px 8px 8px; }
.tg-menu { width: 42px; height: 42px; border-radius: 50%; color: var(--tg-muted); }
.tg-menu:hover:not(:disabled) { background: var(--tg-hover); color: var(--tg-muted); }
.tg-top .searchbox { flex: 1; min-width: 0; }
.tg-top .searchbox .icon { left: 14px; color: var(--tg-muted); }
.tg-top .searchbox input { height: 42px; padding-left: 42px; border-radius: 21px; background: var(--tg-hover); font-size: 15px; color: var(--tg-text); }
.tg-top .searchbox input::placeholder { color: var(--tg-muted); }
.tg-top .searchbox input:hover { background: var(--tg-hover); }
.tg-top .searchbox input:focus { background: var(--tg-side); box-shadow: inset 0 0 0 2px var(--tg-accent); }
.shell.chat-mode .modes { margin: 0 12px; padding: 0; gap: 6px; border-radius: 0; background: none; box-shadow: inset 0 -1px 0 var(--tg-line); }
.shell.chat-mode .mode { height: 38px; border-radius: 0; background: none; box-shadow: none; color: var(--tg-muted); font-size: 14.5px; font-weight: 500; }
.shell.chat-mode .mode.on { color: var(--tg-accent); background: none; box-shadow: inset 0 -3px 0 var(--tg-accent); }
.shell.chat-mode .mode .badge { background: var(--tg-accent); }
.shell.chat-mode .list { padding: 6px 8px 84px; }
.shell.chat-mode .list-empty { color: var(--tg-muted); }
.shell.chat-mode .crow { gap: 12px; min-height: 72px; padding: 8px 10px; border-radius: 12px; color: var(--tg-text); }
.shell.chat-mode .crow:hover { background: var(--tg-hover); }
.shell.chat-mode .crow.on { background: var(--tg-sel); color: #fff; }
.crow-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.crow-line + .crow-line { align-items: center; margin-top: 3px; }
.shell.chat-mode .crow-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; line-height: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow-topic { font-weight: 400; color: var(--tg-muted); }
.crow-time { flex: none; font-size: 12.5px; color: var(--tg-muted); font-variant-numeric: tabular-nums; }
.shell.chat-mode .crow-sub { flex: 1; min-width: 0; font-size: 15px; line-height: 20px; color: var(--tg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell.chat-mode .crow-sub.busy { color: var(--tg-accent); }
.shell.chat-mode .crow-sub.wait { color: #E08A2C; font-weight: 500; }
.crow-badge { flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--tg-accent); color: #fff; font-size: 12.5px; font-weight: 600; line-height: 22px; text-align: center; }
.shell.chat-mode .crow.on .crow-topic, .shell.chat-mode .crow.on .crow-time, .shell.chat-mode .crow.on .crow-sub { color: rgba(255, 255, 255, .85); }
.shell.chat-mode .crow.on .crow-badge { background: #fff; color: var(--tg-accent); }
.fab { position: absolute; right: 18px; bottom: 18px; z-index: 3; width: 56px; height: 56px; border-radius: 50%; background: var(--tg-accent); color: #fff; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); transition: transform .15s; }
.fab:hover { background: var(--tg-accent-2); transform: scale(1.04); }

/* the conversation: header, wallpaper, bubbles */
.shell.chat-mode .tg-head { flex: none; height: 58px; margin: 10px 10px 0; padding: 0 8px 0 14px; border-radius: 16px; background: var(--tg-side); box-shadow: var(--tg-shadow); }
.shell.chat-mode .tg-head h1 { font-size: 17px; }
.shell.chat-mode .tg-head .nm2 { font-size: 16px; font-weight: 600; color: var(--tg-text); }
.shell.chat-mode .tg-head .topic { color: var(--tg-muted); font-weight: 400; }
.shell.chat-mode .tg-head .st { font-size: 13.5px; color: var(--tg-muted); }
.shell.chat-mode .tg-head .st.typing { color: var(--tg-accent); }
.shell.chat-mode .tg-head .ib { width: 40px; height: 40px; border-radius: 50%; color: var(--tg-muted); }
.shell.chat-mode .banner { margin: 8px auto 0; border-radius: 10px; }
.shell.chat-mode .msgs { padding: 10px 0 8px; }
.shell.chat-mode .msgs-inner { max-width: 780px; padding: 0 20px; }
.shell.chat-mode .date, .shell.chat-mode .sysline { align-self: center; margin: 10px auto 6px; padding: 3px 10px; border-radius: 13px; background: var(--tg-pill); color: #fff; font-size: 13.5px; font-weight: 500; }
.shell.chat-mode .sysline.bad { background: #E5533D; }
.shell.chat-mode .sysline.note { background: var(--tg-pill); font-weight: 400; }
.shell.chat-mode .welcome { margin: 14vh auto 0; padding: 18px 22px; border-radius: 18px; background: var(--tg-pill); color: #fff; gap: 8px; }
.shell.chat-mode .welcome strong { color: #fff; font-family: var(--font); font-size: 17px; font-weight: 600; }
.shell.chat-mode .welcome span { font-size: 14px; line-height: 1.6; }
.shell.chat-mode .row { position: relative; display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; }
.shell.chat-mode .row.first { margin-top: 8px; }
.shell.chat-mode .row.u { justify-content: flex-end; }
.shell.chat-mode .row > .av { flex: none; }
.shell.chat-mode .row .spacer { flex: none; width: 34px; }
.shell.chat-mode .bubble { position: relative; max-width: min(75%, 560px); min-width: 74px; padding: 6px 10px 7px 11px; border-radius: 16px; background: var(--tg-in); color: var(--tg-text);
  font-size: 15.5px; line-height: 1.42; overflow-wrap: anywhere; box-shadow: var(--tg-shadow); }
.shell.chat-mode .row.a .bubble { max-width: min(82%, 640px); }
.shell.chat-mode .row.u .bubble { background: var(--tg-out); }
.shell.chat-mode .row.last.u .bubble { border-bottom-right-radius: 4px; }
.shell.chat-mode .row.last.a .bubble { border-bottom-left-radius: 4px; }
/* the tail on the last bubble of a run, curved as in Telegram */
.shell.chat-mode .row.last .bubble::after { content: ""; position: absolute; bottom: 0; width: 10px; height: 18px; }
.shell.chat-mode .row.last.u .bubble::after { right: -8px; background: var(--tg-out); clip-path: path('M0,0 C0,9 2.5,15 10,18 L0,18 Z'); }
.shell.chat-mode .row.last.a .bubble::after { left: -8px; background: var(--tg-in); clip-path: path('M10,0 C10,9 7.5,15 0,18 L10,18 Z'); }
.shell.chat-mode .who { margin-bottom: 2px; font-size: 14px; font-weight: 600; line-height: 18px; }
.shell.chat-mode .to { color: var(--tg-out-meta); font-size: 13px; margin-bottom: 2px; }
.shell.chat-mode .ts { position: absolute; right: 9px; bottom: 5px; display: inline-flex; align-items: center; gap: 3px; font-size: 12px; line-height: 14px; color: var(--tg-in-meta); white-space: nowrap; font-variant-numeric: tabular-nums; }
.shell.chat-mode .row.u .ts, .shell.chat-mode .row.u .ts .icon { color: var(--tg-out-meta); }
.shell.chat-mode .ts .icon.wait { opacity: .8; }
/* room for the time on the last line of text */
.shell.chat-mode .bubble .mc.plain { white-space: pre-wrap; }
.shell.chat-mode .bubble .mc.plain::after { content: ""; display: inline-block; width: 46px; height: 1px; }
.shell.chat-mode .row.u .bubble .mc.plain::after { width: 62px; }
.shell.chat-mode .bubble .mc > :last-child:not(ul):not(ol):not(.code-block):not(.table-wrap):not(blockquote)::after,
.shell.chat-mode .bubble .mc > ul:last-child > li:last-child::after, .shell.chat-mode .bubble .mc > ol:last-child > li:last-child::after { content: ""; display: inline-block; width: 46px; height: 1px; }
.shell.chat-mode .bubble .mc.streaming > :last-child:not(ul):not(ol):not(.code-block):not(.table-wrap)::after,
.shell.chat-mode .bubble .mc.streaming:empty::after { width: 9px; height: 9px; margin: 0 46px 0 4px; }
.shell.chat-mode .bubble.tall { padding-bottom: 22px; }
.shell.chat-mode .bubble .mc { font-size: inherit; line-height: inherit; }
/* Text with levels, as in the Android app: headings, strong words, callouts, lists, tables and code each look
   different, so a long answer can be scanned. */
.shell.chat-mode .bubble .mc p { margin: 0 0 .65em; }
.shell.chat-mode .bubble .mc > :first-child { margin-top: 0; }
.shell.chat-mode .bubble .mc > :last-child { margin-bottom: 0; }
.shell.chat-mode .bubble .mc strong, .shell.chat-mode .bubble .mc b { font-weight: 750; }
.shell.chat-mode .bubble .mc em { font-style: italic; }
.shell.chat-mode .bubble .mc h1, .shell.chat-mode .bubble .mc h2, .shell.chat-mode .bubble .mc h3 { margin: 16px 0 9px; font-size: 19px; font-weight: 750; line-height: 1.4; }
.shell.chat-mode .bubble .mc h1 { font-size: 21px; }
.shell.chat-mode .bubble .mc h4, .shell.chat-mode .bubble .mc h5, .shell.chat-mode .bubble .mc h6 { margin: 12px 0 6px; font-size: 16px; font-weight: 750; line-height: 1.4; }
.shell.chat-mode .bubble .mc blockquote, .shell.chat-mode .bubble .mc .callout { margin: 10px 0; padding: 10px 12px; border-left: 3px solid var(--tg-accent); border-radius: 0 8px 8px 0; background: var(--tg-callout); color: inherit; }
.shell.chat-mode .bubble .mc blockquote > :last-child { margin-bottom: 0; }
.shell.chat-mode .bubble .mc ul, .shell.chat-mode .bubble .mc ol { margin: 0 0 .65em; padding-left: 1.4em; }
.shell.chat-mode .bubble .mc li { margin: 4px 0; }
.shell.chat-mode .bubble .mc li > ul, .shell.chat-mode .bubble .mc li > ol { margin: 4px 0 0; }
.shell.chat-mode .bubble .mc li::marker { color: var(--tg-accent); font-weight: 600; }
.shell.chat-mode .bubble .mc li input { width: 15px; height: 15px; margin: 0 6px 0 0; vertical-align: -2px; accent-color: var(--tg-accent); }
.shell.chat-mode .bubble .mc li:has(> input) { list-style: none; margin-left: -1.2em; }
.shell.chat-mode .bubble .mc hr { margin: 16px 0; border: 0; border-top: 1px solid var(--tg-rule); }
.shell.chat-mode .bubble .mc a { color: var(--tg-link); text-decoration: none; }
.shell.chat-mode .bubble .mc a:hover { text-decoration: underline; }
.shell.chat-mode .bubble .mc :not(pre) > code { padding: 1px 5px; border-radius: 5px; background: var(--tg-chip); font-size: 13px; }
.shell.chat-mode .bubble .table-wrap { margin: 10px 0; }
.shell.chat-mode .bubble .mc table { min-width: 100%; border-collapse: collapse; font-size: 14px; }
.shell.chat-mode .bubble .mc th, .shell.chat-mode .bubble .mc td { padding: 7px 10px; border: 1px solid var(--tg-rule); text-align: left; white-space: nowrap; }
.shell.chat-mode .bubble .mc th { background: var(--tg-th); font-weight: 600; }
.shell.chat-mode .bubble .code-block { margin: 12px 0; border-radius: 9px; border: 0; background: #18232D; }
.shell.chat-mode .bubble .code-block pre code { font-size: 13px; line-height: 1.6; }
.shell.chat-mode .bubble .thumbs { margin: -2px -7px 5px -8px; gap: 3px; }
.shell.chat-mode .bubble .thumb-btn { border-radius: 12px; }
.shell.chat-mode .bubble .thumb { max-width: 340px; max-height: 300px; }
.shell.chat-mode .bubble .chips { flex-direction: column; gap: 6px; margin: 2px 0 4px; }
.shell.chat-mode .bubble .chip { width: auto; min-width: 230px; max-width: 340px; padding: 2px 0; border-radius: 0; background: none; box-shadow: none; }
.shell.chat-mode .bubble .chip:hover { background: none; }
.shell.chat-mode .bubble .chip:hover .chip-name { color: var(--tg-accent); }
.shell.chat-mode .bubble .fext { width: 46px; height: 46px; border-radius: 50%; background: var(--tg-accent); color: #fff; }
.shell.chat-mode .row.u .bubble .fext { background: var(--tg-out-meta); }
.shell.chat-mode .bubble .chip-name { font-size: 15px; }
.shell.chat-mode .bubble .chip-size { font-size: 13px; color: var(--tg-in-meta); }
.shell.chat-mode .row.u .bubble .chip-size { color: var(--tg-out-meta); }
.shell.chat-mode .bubble .sources { margin-top: 6px; padding: 5px 8px; border-radius: 8px; background: var(--tg-chip); font-size: 12.5px; }
.shell.chat-mode .act { flex: none; align-self: center; width: 30px; height: 30px; border-radius: 50%; background: var(--tg-pill); color: #fff; opacity: 0; }
.shell.chat-mode .row:hover .act, .shell.chat-mode .act:focus-visible { opacity: 1; }
.shell.chat-mode .act:hover { background: var(--tg-accent); color: #fff; }
.shell.chat-mode .fail { align-self: flex-end; padding: 2px 10px; border-radius: 10px; background: var(--tg-side); }
.shell.chat-mode .think { align-self: flex-start; max-width: min(82%, 640px); margin: 8px 0 2px; padding: 4px 12px; border-radius: 14px; background: var(--tg-pill); color: #fff; font-size: 13px; }
.shell.chat-mode .think summary:hover { background: none; color: #fff; }
.shell.chat-mode .think-text { border-left-color: rgba(255, 255, 255, .45); }
.shell.chat-mode .think.in-group, .shell.chat-mode .tool.in-group, .shell.chat-mode .ask.in-group, .shell.chat-mode .askline.in-group { margin-left: 40px; }
.shell.chat-mode .tool { align-self: flex-start; margin: 6px 0 0; padding: 4px 12px; border-radius: 14px; background: var(--tg-pill); color: #fff; font-size: 13.5px; }
.shell.chat-mode .tool .dots i { background: #fff; }
.shell.chat-mode .askline { padding: 3px 10px; border-radius: 12px; background: var(--tg-pill); color: #fff; }
.shell.chat-mode .ask { max-width: 560px; background: var(--tg-side); box-shadow: var(--tg-shadow); }
.shell.chat-mode .ask-actions .pbtn:not(.ghost) { background: var(--tg-accent); }
.shell.chat-mode .jump { left: auto; right: 22px; bottom: 12px; margin: 0; width: 46px; height: 46px; background: var(--tg-side); color: var(--tg-muted); box-shadow: var(--tg-shadow); }

/* the composer: a pill with the paperclip and the text, and the round send button */
.shell.chat-mode .tg-bar { padding: 6px 20px 14px; background: transparent; }
.tg-barrow { max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; }
.tg-pill { flex: 1; min-width: 0; display: flex; flex-direction: column; border-radius: 22px; background: var(--tg-side); box-shadow: var(--tg-shadow); }
.tg-pill .rcpt { padding: 8px 14px 0; color: var(--tg-muted); }
.tg-pill .pending { padding: 8px 10px 0; }
.tg-pill .pitem { background: var(--tg-hover); box-shadow: none; }
.tg-irow { display: flex; align-items: flex-end; min-height: 54px; padding: 0 8px 0 6px; }
.tg-attach { flex: none; width: 42px; height: 54px; display: grid; place-items: center; color: var(--tg-muted); }
.tg-attach .icon { transform: rotate(45deg); }
.tg-attach:hover:not(:disabled) { color: var(--tg-accent); }
.tg-attach:disabled { opacity: .4; }
.shell.chat-mode .tg-input { flex: 1; min-height: 54px; max-height: 200px; padding: 15px 6px; color: var(--tg-text); font-size: 16px; line-height: 24px; }
.shell.chat-mode .tg-input::placeholder { color: var(--tg-muted); }
.shell.chat-mode .tg-send { flex: none; width: 54px; height: 54px; border-radius: 50%; background: var(--tg-side); color: var(--tg-accent); box-shadow: var(--tg-shadow); opacity: 1; }
.shell.chat-mode .tg-send.ready, .shell.chat-mode .tg-send.stop { background: var(--tg-accent); color: #fff; }
.shell.chat-mode .tg-send:hover:not(:disabled) { background: var(--tg-accent-2); color: #fff; }
.shell.chat-mode .tg-send:disabled { background: var(--tg-side); color: var(--tg-accent); opacity: 1; cursor: default; }
.shell.chat-mode .drop { background: color-mix(in srgb, var(--tg-side) 70%, transparent); }
.shell.chat-mode .drop-box { border-color: var(--tg-accent); color: var(--tg-accent); background: var(--tg-side); }
.shell.chat-mode .tog.on { background: color-mix(in srgb, var(--tg-accent) 14%, transparent); color: var(--tg-accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tg-accent) 45%, transparent); }

/* a new conversation, and the library */
.tg-home { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.tg-card { width: min(440px, 100%); max-height: 86vh; overflow-y: auto; padding: 6px 0 10px; border-radius: 18px; background: var(--tg-side); color: var(--tg-text); box-shadow: 0 4px 24px rgba(0, 0, 0, .18); }
.tg-card-head { display: flex; align-items: center; gap: 6px; padding: 10px 18px 8px; }
.tg-card-head h2 { font-size: 19px; font-weight: 600; }
.tg-card-sect { padding: 12px 18px 4px; color: var(--tg-accent); font-size: 14.5px; font-weight: 500; }
.tg-card-note { padding: 10px 18px; color: var(--tg-muted); font-size: 14px; line-height: 1.6; }
.tg-card-note.warn { color: #C47A18; }
.tg-card-actions { padding: 4px 18px 10px; }
.tg-pick { display: flex; align-items: center; gap: 14px; width: 100%; padding: 8px 18px; text-align: left; }
.tg-pick:hover { background: var(--tg-hover); }
.tg-pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tg-pick-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-pick-name.accent { color: var(--tg-accent); }
.tg-pick-sub { font-size: 14px; color: var(--tg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-pick-sub .on { color: var(--tg-accent); }
.tg-group-av { background: var(--tg-accent); color: #fff; }
.shell.chat-mode .tg-panel { margin: 10px; border-radius: 16px; background: var(--tg-side); color: var(--tg-text); }
.shell.chat-mode .tg-panel .card { box-shadow: 0 0 0 1px var(--tg-line); }

@media (max-width: 760px) {
  .shell.chat-mode, .shell.chat-mode.side-off { grid-template-columns: minmax(0, 1fr); }
  .shell.chat-mode::before { -webkit-mask-size: 180px 180px; mask-size: 180px 180px; }
  .shell.chat-mode .side { margin: 0; border-radius: 0; box-shadow: none; }
  .shell.chat-mode .tg-head { margin: 0; border-radius: 0; height: 56px; }
  .shell.chat-mode .msgs-inner { padding: 0 10px; }
  .shell.chat-mode .tg-bar { padding: 6px 8px 8px; }
  .shell.chat-mode .tg-send { width: 50px; height: 50px; }
  .tg-irow { min-height: 50px; }
  .shell.chat-mode .tg-input { min-height: 50px; padding: 13px 6px; }
  .fab { bottom: 86px; }
  .shell.chat-mode .tabbar { background: var(--tg-side); border-top-color: var(--tg-line); }
  .shell.chat-mode .tb.on { color: var(--tg-accent); }
  .shell.chat-mode .tb.on .tb-icon { background: color-mix(in srgb, var(--tg-accent) 14%, transparent); }
  .shell.chat-mode .bubble, .shell.chat-mode .row.a .bubble { max-width: 86%; }
  .shell.chat-mode .tg-panel { margin: 0; border-radius: 0; }
  .shell.chat-mode .act { display: none; }
}
