xagent-pi 0.2.9

Self-contained local brain (chat UI + API + SSE) for the Pi agent, tunneled into xagent-service.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
:root {
    --content-max: 1180px;
    --sidebar: #f2f3f5;
    --surface: #ffffff;
    --surface-soft: #f7f7f8;
    --border: #dedfe2;
    --border-soft: #e9e9eb;
    --text: #202124;
    --muted: #6d7178;
    --hint: #93979d;
    --accent: #1267d6;
    --accent-soft: #e3efff;
    --danger: #c9342d;
    --success: #25845b;
    --file-preview-bg: #f7f7f8;
    --file-preview-text: #202124;
    --code-bg: #f6f8fa;
    --code-text: #24292f;
    --code-border: #d8dee4;
    --command-prompt: #28704d;
    --tool-error-text: #b4231c;
    --diff-remove-bg: #ffebe9;
    --diff-remove-text: #9c302b;
    --diff-add-bg: #dafbe1;
    --diff-add-text: #236b47;
}

@media (prefers-color-scheme: dark) {
    :root {
        --sidebar: #17191d;
        --surface: #1b1d21;
        --surface-soft: #23262b;
        --border: #393d43;
        --border-soft: #2e3238;
        --text: #eceef1;
        --muted: #a5aab2;
        --hint: #777e88;
        --accent: #6da8f7;
        --accent-soft: #203653;
        --danger: #f07870;
        --success: #69bd8d;
        --file-preview-bg: #202328;
        --file-preview-text: #e1e4e8;
        --code-bg: #202328;
        --code-text: #e1e4e8;
        --code-border: #363a40;
        --command-prompt: #72b98f;
        --tool-error-text: #f3aaa5;
        --diff-remove-bg: #3d2022;
        --diff-remove-text: #ffb4ae;
        --diff-add-bg: #173528;
        --diff-add-text: #8ed5ad;
    }
}

.app-shell { display: grid; grid-template-columns: clamp(270px, 21vw, 320px) minmax(0, 1fr); width: 100%; height: 100dvh; background: var(--surface); }
button { border: 0; background: none; cursor: pointer; }
.icon-button { display: inline-grid; width: 36px; height: 36px; place-items: center; padding: 0; border-radius: 6px; color: var(--muted); }
.icon-button:hover { background: var(--surface-soft); color: var(--text); }

.sidebar { display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--border); background: var(--sidebar); padding: max(14px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.brand-row { display: flex; height: 42px; align-items: center; gap: 10px; padding: 0 5px; }
.brand-mark { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 7px; background: #202124; color: white; }
.brand-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; line-height: 1.2; }
.brand-copy strong { font-size: 14px; font-weight: 650; }
.brand-copy span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.new-mobile { display: none; }
.new-chat { display: flex; width: 100%; height: 40px; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 13px; font-weight: 600; box-shadow: 0 1px 1px rgb(0 0 0 / 3%); }
.new-chat:hover { border-color: var(--muted); background: var(--surface-soft); }
.search-box { display: flex; height: 38px; align-items: center; gap: 8px; margin-top: 12px; padding: 0 10px; border: 1px solid transparent; border-radius: 6px; background: color-mix(in srgb, var(--text) 7%, var(--sidebar)); color: var(--muted); }
.search-box:focus-within { border-color: #a9c9f5; background: var(--surface); box-shadow: 0 0 0 2px rgb(18 103 214 / 10%); }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.search-box button { display: grid; padding: 2px; place-items: center; color: var(--muted); }
.session-scroll { min-height: 0; flex: 1; margin: 12px -4px 0; overflow-y: auto; padding: 0 4px; scrollbar-width: thin; }
.session-group { margin-bottom: 17px; }
.session-group h2 { margin: 0 8px 5px; color: var(--hint); font-size: 11px; font-weight: 650; text-transform: uppercase; }
.project-heading { display: flex; min-width: 0; height: 34px; align-items: center; justify-content: space-between; padding: 0 5px 0 8px; color: var(--muted); }
.project-heading button { display: grid; width: 28px; height: 28px; flex: none; place-items: center; border-radius: 5px; color: var(--muted); }
.project-heading button:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.project-heading .project-toggle { display: flex; width: auto; min-width: 0; flex: 1; align-items: center; justify-content: flex-start; gap: 6px; padding: 0 4px; overflow: hidden; }
.project-toggle > svg { flex: none; }
.project-toggle > svg:first-child { transition: transform .15s ease; }
.project-toggle > svg:first-child.expanded { transform: rotate(90deg); }
.project-toggle span { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.project-toggle small { flex: none; color: var(--hint); font-size: 10px; font-weight: 500; }
.project-sessions { margin-left: 18px; padding-left: 9px; border-left: 1px solid var(--border); }
.project-empty { padding: 8px 10px 12px; color: var(--hint); font-size: 11px; }
.session-row { position: relative; display: flex; min-height: 54px; align-items: center; border-radius: 6px; }
.session-row:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.session-row.active { background: color-mix(in srgb, var(--accent) 11%, var(--surface-soft)); box-shadow: inset 2px 0 var(--accent); }
.session-main { display: flex; min-width: 0; flex: 1; flex-direction: column; align-items: flex-start; padding: 9px 34px 9px 10px; text-align: left; }
.session-title { width: 100%; overflow: hidden; font-size: 13px; font-weight: 540; text-overflow: ellipsis; white-space: nowrap; }
.session-time { margin-top: 3px; color: var(--hint); font-size: 11px; }
.row-menu-button { position: absolute; right: 5px; display: none; width: 30px; height: 30px; place-items: center; border-radius: 5px; color: var(--muted); }
.session-row:hover .row-menu-button, .row-menu-button:focus { display: grid; }
.row-menu-button:hover { background: color-mix(in srgb, var(--text) 9%, transparent); }
.row-menu { position: absolute; z-index: 5; top: 43px; right: 4px; width: 132px; padding: 5px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); box-shadow: 0 8px 24px rgb(0 0 0 / 14%); }
.row-menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px; border-radius: 4px; font-size: 13px; text-align: left; }
.row-menu button:hover { background: var(--surface-soft); }
.row-menu .danger { color: var(--danger); }
.sidebar-settings { display: flex; width: 100%; height: 38px; flex: none; align-items: center; gap: 8px; margin-top: 5px; padding: 0 8px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; text-align: left; }
.sidebar-settings:hover { color: var(--text); }
.sidebar-settings.active { background: color-mix(in srgb, var(--accent) 10%, var(--surface-soft)); color: var(--text); }
.brain-status { display: flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.brain-status.offline { color: var(--danger); }
.brain-status.offline .status-dot { background: var(--danger); box-shadow: 0 0 0 3px rgb(201 52 45 / 12%); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgb(37 132 91 / 12%); }
.empty-list { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 42px 12px; color: var(--hint); font-size: 12px; }
.session-skeleton { height: 46px; margin: 6px 4px; border-radius: 5px; background: linear-gradient(90deg, var(--surface-soft), color-mix(in srgb, var(--text) 8%, var(--surface-soft)), var(--surface-soft)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.conversation { position: relative; display: grid; min-width: 0; height: 100dvh; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--surface); }
.conversation-header { display: flex; min-height: 64px; align-items: center; padding: max(8px, env(safe-area-inset-top)) 22px 8px; border-bottom: 1px solid var(--border-soft); background: color-mix(in srgb, var(--surface) 92%, transparent); }
.conversation-title { display: flex; min-width: 0; flex: 1; flex-direction: column; align-items: flex-start; }
.conversation-title > button { display: flex; max-width: 100%; align-items: center; gap: 7px; padding: 1px 0; overflow: hidden; font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.conversation-title > button svg { flex: none; opacity: 0; color: var(--hint); }
.conversation-title > button:hover svg { opacity: 1; }
.conversation-title > span { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted); font-size: 11px; }
.conversation-title i { width: 6px; height: 6px; border-radius: 50%; background: #c88a23; }
.conversation-title i.online { background: var(--success); }
.header-menu { margin-left: auto; }
.conversation-header > .icon-button:not(.mobile-back) + .header-menu { margin-left: 2px; }
.mobile-back { display: none; flex: none; margin-right: 5px; }
.connection-banner { position: absolute; z-index: 4; top: 64px; right: 0; left: 0; padding: 7px 16px; background: color-mix(in srgb, #d89a2b 18%, var(--surface)); color: color-mix(in srgb, #d89a2b 70%, var(--text)); font-size: 12px; text-align: center; }
.timeline { position: relative; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.thread { width: min(100%, var(--content-max)); min-height: 100%; margin: 0 auto; padding: 34px clamp(14px, 2.5vw, 34px) 54px; }
.message { display: flex; width: 100%; margin-bottom: 26px; }
.message.assistant { justify-content: flex-start; }
.message.user { justify-content: flex-end; }
.assistant-message-body { min-width: 0; max-width: 100%; }
.message-content { min-width: 0; max-width: 100%; font-size: 14px; line-height: 1.72; }
.message.user .message-content { max-width: min(78%, 620px); padding: 10px 13px; border-radius: 8px 8px 2px 8px; background: var(--surface-soft); }
.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }
.message-content p { margin: 0 0 12px; white-space: pre-wrap; }
.message-content ul, .message-content ol { padding-left: 22px; }
.message-content a { color: var(--accent); }
.message-content pre { max-width: 100%; overflow-x: auto; padding: 14px; border: 1px solid var(--code-border); border-radius: 6px; background: var(--code-bg); color: var(--code-text); font-size: 12px; line-height: 1.6; }
.markdown-code-block { max-width: 100%; margin: 12px 0; overflow: hidden; border: 1px solid var(--code-border); border-radius: 6px; background: var(--code-bg); }
.code-block-toolbar { display: flex; height: 34px; align-items: center; justify-content: space-between; padding: 0 7px 0 12px; border-bottom: 1px solid var(--code-border); color: var(--muted); font-size: 10px; }
.code-block-toolbar > span { overflow: hidden; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.code-block-toolbar button { display: inline-flex; height: 26px; flex: none; align-items: center; gap: 5px; padding: 0 6px; border-radius: 4px; color: var(--muted); font-size: 10px; }
.code-block-toolbar button:hover, .code-block-toolbar button:focus-visible { background: var(--surface); color: var(--text); }
.message-content .markdown-code-block pre { margin: 0; border: 0; border-radius: 0; }
.message-content code:not(pre code) { padding: 2px 5px; border-radius: 4px; background: var(--surface-soft); color: var(--danger); font-size: .9em; }
.message-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.message-content th, .message-content td { padding: 7px 10px; border: 1px solid var(--border); }
.message-footer { display: flex; min-height: 24px; align-items: center; gap: 5px; margin-top: 5px; color: var(--hint); font-size: 10px; }
.message-copy { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 4px; color: var(--hint); }
.message-copy:hover, .message-copy:focus-visible { background: var(--surface-soft); color: var(--text); }
.reasoning, .tool-call { width: 100%; margin: -11px 0 24px; border: 1px solid var(--border-soft); border-radius: 6px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }
.reasoning summary, .tool-call summary { display: flex; min-height: 42px; align-items: center; gap: 8px; padding: 5px 11px; cursor: pointer; list-style: none; }
.reasoning summary svg:last-child, .tool-call summary svg:last-child { margin-left: auto; transition: transform .15s; }
.reasoning[open] summary svg:last-child, .tool-call[open] summary svg:last-child { transform: rotate(180deg); }
.reasoning > div { padding: 0 12px 12px; white-space: pre-wrap; }
.tool-call.error { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.tool-icon { display: grid; width: 25px; height: 25px; flex: none; place-items: center; border-radius: 5px; background: color-mix(in srgb, var(--text) 8%, var(--surface)); color: var(--muted); }
.tool-read .tool-icon { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.tool-write .tool-icon { background: color-mix(in srgb, var(--success) 14%, var(--surface)); color: var(--success); }
.tool-edit .tool-icon { background: color-mix(in srgb, #c58b2b 15%, var(--surface)); color: color-mix(in srgb, #c58b2b 75%, var(--text)); }
.tool-bash .tool-icon { background: color-mix(in srgb, #8172ae 16%, var(--surface)); color: color-mix(in srgb, #8172ae 75%, var(--text)); }
.tool-summary-copy { display: flex; min-width: 0; flex: 1; align-items: baseline; gap: 9px; }
.tool-summary-copy strong { flex: none; color: var(--text); font-size: 12px; font-weight: 650; }
.tool-summary-copy > span { min-width: 0; overflow: hidden; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.tool-state { flex: none; color: var(--hint); font-size: 10px; }
.tool-call.error .tool-state { color: var(--danger); }
.tool-body { border-top: 1px solid var(--border-soft); background: var(--surface); }
.tool-body pre { max-height: 320px; margin: 0; overflow: auto; padding: 11px 12px; font: 11px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-meta { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); color: var(--hint); }
.tool-code { color: var(--text); }
.tool-command, .tool-output { background: var(--code-bg); color: var(--code-text); }
.tool-command + .tool-output { border-top: 1px solid var(--code-border); }
.tool-command span { color: var(--command-prompt); user-select: none; }
.tool-result { max-height: 180px; overflow: auto; padding: 9px 12px; border-top: 1px solid var(--border-soft); color: var(--muted); line-height: 1.55; white-space: pre-wrap; }
.tool-diff + .tool-diff { border-top: 1px solid var(--border-soft); }
.tool-diff .diff-remove { background: var(--diff-remove-bg); color: var(--diff-remove-text); }
.tool-diff .diff-add { border-top: 1px solid var(--code-border); background: var(--diff-add-bg); color: var(--diff-add-text); }
.tool-call.error .tool-output, .tool-call.error .tool-result { color: var(--tool-error-text); }
.thinking-row { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.thinking-row > span { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
.thinking-row > span:nth-child(2) { animation-delay: .15s; }.thinking-row > span:nth-child(3) { animation-delay: .3s; }
.thinking-row em { margin-left: 6px; font-size: 12px; font-style: normal; }
@keyframes pulse { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }
.thread-empty { display: flex; min-height: 55vh; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; }
.thread-empty .empty-icon { display: grid; width: 48px; height: 48px; margin-bottom: 15px; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); color: var(--text); }
.thread-empty strong { color: var(--text); font-size: 15px; }.thread-empty span { margin-top: 5px; font-size: 12px; }
.message-loading { display: flex; justify-content: center; gap: 6px; padding-top: 25vh; }.message-loading span { width: 6px; height: 6px; border-radius: 50%; background: var(--hint); animation: pulse 1.2s infinite; }
.jump-bottom { position: sticky; bottom: 14px; left: calc(50% - 18px); display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); box-shadow: 0 4px 12px rgb(0 0 0 / 10%); }
.empty-conversation { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--hint); gap: 7px; }.empty-conversation strong { margin-top: 8px; color: var(--text); }

.file-browser-backdrop { display: none; }
.file-browser { position: absolute; z-index: 10; inset: 0; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); background: var(--surface); }
.file-browser-header { display: flex; width: min(94%, 1600px); min-height: 64px; align-items: center; gap: 9px; margin: 0 auto; padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.file-search { display: flex; min-width: 0; height: 42px; flex: 1; align-items: center; gap: 10px; padding: 0 12px; border-radius: 7px; background: var(--surface-soft); color: var(--muted); }
.file-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; }
.file-search button { display: grid; place-items: center; color: var(--muted); }
.file-browser-header > .icon-button { width: 38px; height: 38px; flex: none; color: var(--muted); }
.file-browser-header > .icon-button:hover, .file-browser-header > .icon-button.active { background: var(--surface-soft); color: var(--text); }
.file-tabs { display: grid; min-height: 56px; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border-soft); }
.file-tabs button { position: relative; color: var(--muted); font-size: 13px; font-weight: 600; }
.file-tabs button.active { color: var(--text); }
.file-tabs button.active::after { position: absolute; right: calc(50% - 24px); bottom: 0; left: calc(50% - 24px); height: 2px; border-radius: 2px; background: var(--text); content: ''; }
.file-current-path { width: min(94%, 1600px); overflow: hidden; margin: 0 auto; padding: 9px 0; border-bottom: 1px solid var(--border-soft); color: var(--muted); font: 11px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs { display: flex; min-height: 42px; align-items: center; gap: 2px; overflow-x: auto; padding: 0 14px; border-bottom: 1px solid var(--border-soft); color: var(--muted); scrollbar-width: none; }
.breadcrumbs span { display: flex; align-items: center; gap: 2px; }
.breadcrumbs button { max-width: 140px; padding: 5px 3px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs button:hover { color: var(--text); }
.file-list { width: min(94%, 1600px); min-height: 0; overflow-y: auto; margin: 0 auto; padding: 7px 0 18px; }
.file-row { display: grid; width: 100%; min-height: 54px; grid-template-columns: 18px 28px minmax(0, 1fr) 38px; align-items: center; gap: 8px; padding: 5px 9px; border-radius: 5px; text-align: left; cursor: pointer; }
.file-row:hover { background: var(--surface-soft); }
.file-row > svg { color: var(--muted); }
.file-row-copy { display: flex; min-width: 0; flex-direction: column; gap: 3px; overflow: hidden; }
.file-row-copy strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.file-row-copy small { overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.file-row.directory { min-height: 50px; }
.file-row.directory .file-row-copy { grid-column: 3 / -1; }
.directory-chevron { transition: transform .15s ease; }
.directory-chevron.expanded { transform: rotate(90deg); }
.directory-loading { min-height: 34px; color: var(--hint); font-size: 11px; line-height: 34px; }
.file-root { display: flex; min-height: 48px; align-items: center; gap: 12px; padding: 5px 15px; }
.file-root strong { font-size: 14px; }
.file-download { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 5px; color: var(--muted); }
.file-download:hover { background: var(--surface); color: var(--text); }
.files-empty { padding: 54px 12px; color: var(--hint); font-size: 12px; text-align: center; }
.file-error { position: absolute; z-index: 2; top: 103px; right: 3%; left: 3%; padding: 9px 10px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); border-radius: 5px; background: color-mix(in srgb, var(--danger) 9%, var(--surface)); color: var(--danger); font-size: 12px; box-shadow: 0 4px 12px rgb(0 0 0 / 8%); }
.files-loading { position: absolute; top: 121px; right: 0; left: 0; display: flex; justify-content: center; gap: 5px; padding: 14px; background: color-mix(in srgb, var(--surface) 86%, transparent); }
.files-loading span { width: 5px; height: 5px; border-radius: 50%; background: var(--hint); animation: pulse 1.2s infinite; }
.file-preview { display: grid; min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
.file-preview-heading { display: grid; min-height: 48px; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 6px 10px; border-bottom: 1px solid var(--border-soft); }
.file-preview-heading > span { overflow: hidden; font-size: 12px; font-weight: 600; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-heading small { margin-left: 7px; color: var(--hint); font-weight: 400; }
.back-to-files { display: flex; height: 34px; align-items: center; gap: 5px; padding: 0 7px; border-radius: 5px; color: var(--muted); font-size: 12px; }
.back-to-files:hover { background: var(--surface-soft); color: var(--text); }
.file-preview pre { min-width: 0; min-height: 0; margin: 0; overflow: auto; padding: 16px; background: var(--file-preview-bg); color: var(--file-preview-text); font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 4; white-space: pre; }
.git-diff-view { width: min(94%, 1600px); min-height: 0; overflow: auto; margin: 0 auto; }
.git-diff-view pre { min-width: max-content; margin: 0; padding: 14px 0 30px; color: var(--file-preview-text); font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 4; }
.git-diff-view pre span { display: block; min-height: 1.55em; padding: 0 10px; white-space: pre; }
.git-diff-view .diff-add-line { background: var(--diff-add-bg); color: var(--diff-add-text); }
.git-diff-view .diff-remove-line { background: var(--diff-remove-bg); color: var(--diff-remove-text); }
.git-diff-view .diff-file { color: var(--muted); font-weight: 600; }
.git-diff-view .diff-hunk { background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--accent); }

.composer-shell { position: relative; z-index: 2; padding: 8px max(24px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); background: linear-gradient(to bottom, rgb(255 255 255 / 0%), var(--surface) 12px); }
.composer, .attachments, .composer-note, .settings-popover { width: min(100%, var(--content-max)); margin-right: auto; margin-left: auto; }
.composer { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 4px 18px rgb(0 0 0 / 7%); }
.composer:focus-within { border-color: #91b8ec; box-shadow: 0 0 0 2px rgb(18 103 214 / 10%), 0 4px 18px rgb(0 0 0 / 6%); }
.composer textarea { display: block; width: 100%; min-height: 48px; max-height: 180px; resize: none; border: 0; outline: 0; padding: 14px 15px 6px; background: transparent; color: var(--text); font-size: 14px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--hint); }
.composer-toolbar { display: flex; min-height: 43px; align-items: center; justify-content: space-between; padding: 4px 7px 7px; }
.toolbar-group { display: flex; min-width: 0; align-items: center; gap: 3px; }
.model-button { display: flex; min-width: 0; max-width: 240px; height: 34px; align-items: center; gap: 6px; padding: 0 8px; border-radius: 6px; color: var(--muted); font-size: 12px; }
.model-button:hover { background: var(--surface-soft); color: var(--text); }.model-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send-button { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 6px; background: var(--text); color: white; }.send-button:disabled { cursor: default; opacity: .25; }
.stop-button { display: flex; height: 34px; align-items: center; gap: 7px; padding: 0 10px; border-radius: 6px; background: var(--text); color: white; font-size: 12px; }
.composer-note { padding-top: 5px; color: var(--hint); font-size: 10px; text-align: center; }
.attachments { display: flex; gap: 7px; overflow-x: auto; padding: 0 0 7px; }
.attachment { display: flex; min-width: 0; max-width: 230px; flex: none; align-items: center; gap: 7px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-soft); font-size: 11px; }.attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.attachment button { display: grid; padding: 0; place-items: center; color: var(--muted); }
.settings-popover { position: absolute; right: 24px; bottom: calc(100% - 4px); left: 24px; max-width: 430px; padding: 13px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); box-shadow: 0 12px 35px rgb(0 0 0 / 14%); }
.popover-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 13px; font-weight: 650; }.popover-heading button { display: grid; padding: 3px; place-items: center; color: var(--muted); }
.settings-popover label { display: grid; grid-template-columns: 90px 1fr; align-items: center; margin-top: 8px; color: var(--muted); font-size: 12px; }.settings-popover select { min-width: 0; height: 36px; border: 1px solid var(--border); border-radius: 5px; outline: 0; padding: 0 9px; background: var(--surface); color: var(--text); }

.dialog-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; padding: 20px; place-items: center; background: rgb(20 22 25 / 42%); }
.dialog { width: min(100%, 410px); padding: 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 18px 50px rgb(0 0 0 / 22%); }.dialog h2 { margin: 0 0 15px; font-size: 16px; }.dialog p { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }.dialog input { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 6px; outline: 0; padding: 0 10px; }.dialog input:focus { border-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }.dialog-actions button { min-width: 70px; height: 36px; border: 1px solid var(--border); border-radius: 6px; padding: 0 13px; }.dialog-actions .primary { border-color: var(--accent); background: var(--accent); color: white; }.dialog-actions .danger { border-color: var(--danger); background: var(--danger); color: white; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dialog-heading h2 { margin: 0; }
.directory-dialog { display: flex; width: min(100%, 620px); height: min(680px, calc(100dvh - 40px)); flex-direction: column; }
.directory-current { display: block; flex: none; overflow-x: auto; padding: 9px 10px; border: 1px solid var(--border-soft); border-radius: 5px; background: var(--surface-soft); color: var(--muted); font-size: 12px; white-space: nowrap; }
.directory-list { min-height: 0; flex: 1; overflow-y: auto; margin-top: 10px; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); padding: 5px 0; }
.directory-list > button { display: grid; width: 100%; min-height: 40px; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 5px; text-align: left; }
.directory-list > button:hover { background: var(--surface-soft); }
.directory-list > button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-list > div { padding: 40px 8px; color: var(--hint); font-size: 12px; text-align: center; }
.directory-error { margin-top: 8px; color: var(--danger); font-size: 12px; }
.directory-dialog .dialog-actions { flex: none; }
.new-session-dialog { width: min(100%, 480px); }
.session-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-soft); }
.session-mode button { display: flex; height: 38px; align-items: center; justify-content: center; gap: 7px; border-radius: 5px; color: var(--muted); font-size: 13px; }
.session-mode button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 10%); font-weight: 600; }
.session-mode button:disabled { cursor: default; opacity: .35; }
.worktree-name { display: flex; flex-direction: column; gap: 7px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.worktree-name input { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 6px; outline: 0; padding: 0 10px; color: var(--text); }
.worktree-name input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgb(18 103 214 / 10%); }
.dialog-note { margin: 13px 0 0; color: var(--hint); font-size: 12px; }
.settings-page { display: grid; min-width: 0; height: 100dvh; grid-template-rows: 64px minmax(0, 1fr); background: var(--surface); }
.settings-header { display: flex; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--border-soft); }
.settings-header h1 { margin: 0; font-size: 16px; }
.settings-layout { display: grid; min-height: 0; grid-template-columns: 190px minmax(0, 1fr); }
.settings-nav { display: flex; flex-direction: column; gap: 3px; padding: 20px 12px; border-right: 1px solid var(--border-soft); background: var(--surface-soft); }
.settings-nav button { display: flex; height: 38px; align-items: center; gap: 9px; padding: 0 11px; border-radius: 6px; color: var(--muted); font-size: 13px; text-align: left; }
.settings-nav button:hover { background: color-mix(in srgb, var(--text) 7%, var(--surface-soft)); color: var(--text); }
.settings-nav button.active { background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft)); color: var(--text); font-weight: 600; }
.settings-content { width: min(100%, 820px); overflow-y: auto; padding: 36px 42px 70px; }
.settings-content h2 { margin: 0 0 24px; font-size: 20px; }
.settings-rows { border-top: 1px solid var(--border); }
.settings-rows > div { display: grid; min-height: 54px; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 20px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.settings-rows span { color: var(--muted); }
.settings-rows code, .settings-rows strong { min-width: 0; overflow-x: auto; color: var(--text); font-size: 12px; font-weight: 500; text-align: right; white-space: nowrap; }
.account-status { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.account-status > .status-dot { width: 9px; height: 9px; flex: none; }
.account-status > div { display: flex; flex-direction: column; gap: 4px; }
.account-status strong { font-size: 14px; }.account-status span { color: var(--muted); font-size: 12px; }
.account-actions { display: flex; justify-content: flex-end; margin-top: 24px; }
.logout-button { display: flex; height: 38px; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); border-radius: 6px; color: var(--danger); font-size: 13px; font-weight: 600; }
.logout-button:hover { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.logout-button:disabled { cursor: default; opacity: .55; }
.settings-subnav { display: flex; gap: 2px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.settings-subnav button { min-width: 88px; height: 36px; padding: 0 12px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 12px; }
.settings-subnav button.active { border-color: var(--text); color: var(--text); font-weight: 650; }
.pi-defaults { display: grid; gap: 16px; }
.pi-defaults > label { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 20px; color: var(--muted); font-size: 13px; }
.pi-defaults select { width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; background: var(--surface); color: var(--text); }
.pi-settings-actions { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--border-soft); }
.pi-settings-actions > span { min-width: 0; overflow: hidden; color: var(--hint); font: 11px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.primary-action { display: inline-flex; height: 34px; flex: none; align-items: center; justify-content: center; gap: 7px; padding: 0 11px; border-radius: 5px; background: var(--text); color: var(--surface); font-size: 12px; }
.primary-action:disabled { cursor: default; opacity: .45; }
.provider-manager { min-width: 0; }
.provider-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.provider-toolbar > span { color: var(--muted); font-size: 12px; }
.provider-toolbar > div { display: flex; gap: 8px; }
.provider-toolbar button, .models-heading button { display: inline-flex; height: 34px; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; color: var(--text); font-size: 12px; }
.provider-toolbar button:hover, .models-heading button:hover { background: var(--surface-soft); }
.provider-toolbar .primary-action { border-color: var(--text); background: var(--text); color: var(--surface); }
.provider-list { display: grid; gap: 32px; }
.provider-section { border-top: 1px solid var(--border); }
.provider-section > header { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 16px; }
.provider-section > header > div { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.provider-section header strong { font-size: 13px; }.provider-section header span, .provider-section header small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.danger-icon { color: var(--danger); }
.provider-fields, .model-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 16px; }
.provider-fields label, .model-fields label { display: grid; min-width: 0; gap: 6px; }
.provider-fields label > span, .model-fields label > span { color: var(--muted); font-size: 11px; }
.provider-fields input, .model-fields input:not([type="checkbox"]) { width: 100%; height: 36px; min-width: 0; border: 1px solid var(--border); border-radius: 5px; outline: 0; padding: 0 9px; background: var(--surface); color: var(--text); font-size: 12px; }
.provider-fields input:focus, .model-fields input:focus { border-color: #8cadcf; box-shadow: 0 0 0 2px rgb(18 103 214 / 7%); }
.wide-field { grid-column: 1 / -1; }
.secret-input { display: grid; grid-template-columns: minmax(0, 1fr) 36px; }
.secret-input input { border-radius: 5px 0 0 5px; }
.secret-input button { display: grid; place-items: center; border: 1px solid var(--border); border-left: 0; border-radius: 0 5px 5px 0; color: var(--muted); }
.models-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; padding: 14px 0 9px; border-top: 1px solid var(--border-soft); }
.models-heading > strong { font-size: 12px; }
.models-heading button { height: 30px; font-size: 11px; }
.model-editor-list { border-bottom: 1px solid var(--border); }
.model-editor { padding: 15px 0 18px; border-top: 1px solid var(--border-soft); }
.model-editor-heading { display: flex; min-height: 28px; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.model-editor-heading strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.model-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.toggle-field { align-content: start; }
.toggle-field input { width: 17px; height: 17px; margin-top: 3px; accent-color: var(--text); }
.models-empty { padding: 25px 0; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border); color: var(--hint); font-size: 11px; text-align: center; }
.source-toolbar { display: flex; min-width: 0; align-items: center; gap: 8px; margin-bottom: 8px; }
.source-toolbar > code { min-width: 0; flex: 1; overflow: hidden; color: var(--hint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.source-toolbar > button:not(.primary-action), .source-switch button { height: 30px; padding: 0 9px; border-radius: 4px; color: var(--muted); font-size: 11px; }
.source-toolbar > button:not(.primary-action):hover, .source-switch button:hover { background: var(--surface-soft); color: var(--text); }
.source-switch { display: flex; flex: none; padding: 2px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-soft); }.source-switch button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 8%); }
.config-editor { display: block; width: 100%; height: min(58vh, 560px); resize: vertical; border: 1px solid var(--code-border); border-radius: 6px; outline: 0; padding: 14px; background: var(--code-bg); color: var(--code-text); font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
.config-editor:focus { border-color: #9bbde9; box-shadow: 0 0 0 2px rgb(18 103 214 / 8%); }
.pi-settings-status { margin-top: 12px; color: var(--danger); font-size: 12px; }.pi-settings-status.success { color: var(--success); }
.pi-settings-loading { display: flex; justify-content: center; gap: 5px; padding: 80px 0; }.pi-settings-loading span { width: 5px; height: 5px; border-radius: 50%; background: var(--hint); animation: pulse 1.2s infinite; }
.settings-empty { padding: 54px 12px; color: var(--hint); font-size: 12px; text-align: center; }
.about-product { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.about-product > div:last-child { display: flex; flex-direction: column; gap: 3px; }
.about-product strong { font-size: 15px; }.about-product span { color: var(--muted); font-size: 12px; }
.update-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.update-actions > span { color: var(--muted); font-size: 12px; }
.version-current { display: flex; align-items: center; gap: 6px; margin-top: 18px; color: var(--success); font-size: 12px; }

@media (max-width: 720px) {
    .app-shell { display: block; }
    .sidebar, .conversation, .settings-page { width: 100%; height: 100dvh; }
    .conversation, .settings-page { display: none; }
    .app-shell.show-conversation .sidebar { display: none; }
    .app-shell.show-conversation .conversation, .app-shell.show-conversation .settings-page { display: grid; }
    .sidebar { border-right: 0; padding-right: max(12px, env(safe-area-inset-right)); padding-left: max(12px, env(safe-area-inset-left)); }
    .brand-row { height: 48px; }.brand-copy strong { font-size: 14px; }.brand-copy span { max-width: 160px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
    .new-mobile { display: grid; }.new-chat { display: none; }
    .search-box { margin-top: 10px; }
    .session-scroll { margin-top: 15px; }
    .session-row { min-height: 62px; border-bottom: 1px solid rgb(222 223 226 / 65%); border-radius: 0; }
    .session-row.active { background: color-mix(in srgb, var(--accent) 10%, var(--surface-soft)); }
    .session-main { padding: 10px 42px 10px 8px; }.session-title { font-size: 14px; }.session-time { font-size: 12px; }
    .row-menu-button { display: grid; width: 38px; height: 38px; }
    .sidebar-settings { padding-bottom: env(safe-area-inset-bottom); }
    .conversation-header { min-height: 58px; padding-right: max(8px, env(safe-area-inset-right)); padding-left: max(8px, env(safe-area-inset-left)); }
    .mobile-back { display: grid; }.conversation-title > button { font-size: 13px; }.conversation-title > button svg { display: none; }
    .thread { padding: 22px max(10px, env(safe-area-inset-right)) 36px max(10px, env(safe-area-inset-left)); }
    .message { margin-bottom: 22px; }.message-content { font-size: 14px; line-height: 1.65; }
    .message.user .message-content { max-width: 86%; }
    .tool-summary-copy { display: block; }
    .tool-summary-copy > span { display: block; margin-top: 2px; }
    .tool-state { display: none; }
    .tool-body pre { max-height: 250px; }
    .composer-shell { padding: 6px max(10px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
    .composer { border-radius: 7px; }.composer textarea { font-size: 16px; }
    .composer-note { display: none; }.model-button { max-width: 175px; }
    .settings-popover { right: max(10px, env(safe-area-inset-right)); bottom: calc(100% + 1px); left: max(10px, env(safe-area-inset-left)); max-width: none; }
    .dialog-backdrop { align-items: end; padding: 0; }.dialog { width: 100%; padding: 20px max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); border-radius: 8px 8px 0 0; }
    .directory-dialog { height: min(82dvh, 680px); }
    .settings-page { grid-template-rows: 58px minmax(0, 1fr); }
    .settings-header { padding-right: max(12px, env(safe-area-inset-right)); padding-left: max(8px, env(safe-area-inset-left)); }
    .settings-header .mobile-back { display: grid; margin-right: 5px; }
    .settings-layout { display: grid; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
    .settings-nav { flex-direction: row; padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border-soft); background: var(--surface); }
    .settings-nav button { min-width: 96px; flex: 1; justify-content: center; }
    .settings-content { width: 100%; padding: 25px max(18px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
    .settings-content h2 { margin-bottom: 18px; font-size: 18px; }
    .settings-rows > div { grid-template-columns: 92px minmax(0, 1fr); gap: 12px; }
    .pi-defaults > label { grid-template-columns: 1fr; gap: 7px; }
    .pi-settings-actions { align-items: stretch; flex-direction: column; }.pi-settings-actions .primary-action { width: 100%; }
    .provider-toolbar { align-items: stretch; flex-direction: column; }.provider-toolbar > div { display: grid; grid-template-columns: 1fr 1fr; }.provider-toolbar button { width: 100%; }
    .provider-list { gap: 26px; }.provider-fields, .model-fields { grid-template-columns: 1fr; }.wide-field { grid-column: auto; }
    .source-toolbar { flex-wrap: wrap; }.source-toolbar > code { width: 100%; flex-basis: 100%; order: 3; }.source-switch { flex: 1; }.source-switch button { flex: 1; }
    .config-editor { height: 52vh; font-size: 11px; }
    .file-browser-backdrop { position: fixed; inset: 0; }
    .file-browser { position: fixed; top: 0; width: 100%; border-left: 0; padding-top: env(safe-area-inset-top); }
    .file-browser-header, .file-current-path, .file-list, .git-diff-view { width: min(92%, 1600px); }
    .file-list { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; } }