claude-rpc 1.7.4 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,422 @@
1
+ // /settings runtime — vanilla, one IIFE, no build step.
2
+ //
3
+ // `base` is the config as the server showed it; `cfg` is the working copy the
4
+ // form edits. Save sends both, and the server writes only what differs (see
5
+ // src/config-edit.js), so defaults are never frozen into the user's file.
6
+ (function () {
7
+ const $ = (id) => document.getElementById(id);
8
+ const clone = (v) => JSON.parse(JSON.stringify(v));
9
+
10
+ let base = null; // config as loaded
11
+ let cfg = null; // working copy
12
+ let live = {}; // live template variables, for the preview
13
+ let statuses = [];
14
+ let status = 'working';
15
+ let lastTemplateInput = null;
16
+
17
+ // ── tiny DOM helper ────────────────────────────────────────────────────
18
+ function el(tag, attrs, children) {
19
+ const n = document.createElement(tag);
20
+ for (const [k, v] of Object.entries(attrs || {})) {
21
+ if (k === 'class') n.className = v;
22
+ else if (k === 'text') n.textContent = v;
23
+ else if (k.startsWith('on')) n.addEventListener(k.slice(2), v);
24
+ else if (v !== false && v != null) n.setAttribute(k, v === true ? '' : v);
25
+ }
26
+ for (const c of [].concat(children || [])) if (c) n.appendChild(c);
27
+ return n;
28
+ }
29
+
30
+ async function api(path, body) {
31
+ const opts = body === undefined ? {} : {
32
+ method: 'POST',
33
+ headers: { 'content-type': 'application/json' },
34
+ body: JSON.stringify(body),
35
+ };
36
+ let res;
37
+ try { res = await fetch(path, opts); }
38
+ catch { return { error: "Can't reach the dashboard — is `claude-rpc serve` still running?" }; }
39
+ try { return await res.json(); }
40
+ catch { return { error: 'Unexpected reply from the dashboard (' + res.status + ')' }; }
41
+ }
42
+
43
+ // ── config accessors ───────────────────────────────────────────────────
44
+ function statusBlock() {
45
+ cfg.presence = cfg.presence || {};
46
+ cfg.presence.byStatus = cfg.presence.byStatus || {};
47
+ return (cfg.presence.byStatus[status] = cfg.presence.byStatus[status] || {});
48
+ }
49
+ function frames() {
50
+ const b = statusBlock();
51
+ return Array.isArray(b.rotation) ? b.rotation : [];
52
+ }
53
+ // An emptied list is stored as [] when the loaded config had frames there:
54
+ // deleting the key would bring the default frames back on the next load.
55
+ function storeFrames(block, name, list) {
56
+ const had = Array.isArray((((base.presence || {}).byStatus || {})[name] || {}).rotation);
57
+ if (list.length || had) block.rotation = list;
58
+ else delete block.rotation;
59
+ }
60
+ function setFrames(list) { storeFrames(statusBlock(), status, list); }
61
+
62
+ // ── template preview ───────────────────────────────────────────────────
63
+ // Same shape as the daemon's fill: unknown or empty variables render as
64
+ // nothing, then separators left dangling by an empty value are tidied.
65
+ function fill(tpl) {
66
+ if (!tpl) return '';
67
+ return String(tpl)
68
+ .replace(/\{(\w+)\}/g, (m, k) => (live[k] === undefined || live[k] === null ? '' : String(live[k])))
69
+ .replace(/(\s*·\s*)+/g, ' · ')
70
+ .replace(/^\s*·\s*|\s*·\s*$/g, '')
71
+ .trim();
72
+ }
73
+
74
+ function renderPreview() {
75
+ const b = statusBlock();
76
+ $('pv-app').textContent = cfg.appName || 'Claude Code';
77
+ $('pv-details').textContent = fill(b.details) || '—';
78
+ $('pv-state').textContent = fill(b.state);
79
+ const url = (cfg.statusAssets || {})[status] || (cfg.presence || {}).largeImageKey || '';
80
+ const av = $('pv-avatar');
81
+ av.textContent = '';
82
+ if (/^https?:\/\//i.test(url)) av.appendChild(el('img', { src: url, alt: '' }));
83
+ }
84
+
85
+ // ── Card section ───────────────────────────────────────────────────────
86
+ function renderTabs() {
87
+ const root = $('status-tabs');
88
+ root.textContent = '';
89
+ for (const s of statuses) {
90
+ root.appendChild(el('button', {
91
+ role: 'tab', 'aria-selected': String(s === status), text: s,
92
+ onclick: () => { status = s; renderCard(); },
93
+ }));
94
+ }
95
+ }
96
+
97
+ function requiresText(f) {
98
+ return Array.isArray(f.requires) ? f.requires.join(', ') : (f.requires || '');
99
+ }
100
+ function parseRequires(text) {
101
+ const parts = text.split(',').map((s) => s.trim()).filter(Boolean);
102
+ return parts.length === 0 ? undefined : parts.length === 1 ? parts[0] : parts;
103
+ }
104
+
105
+ function templateInput(value, placeholder, label, oninput) {
106
+ return el('input', {
107
+ type: 'text', value: value || '', placeholder, 'aria-label': label, autocomplete: 'off',
108
+ 'data-template': true, oninput: (e) => oninput(e.target.value),
109
+ });
110
+ }
111
+
112
+ function renderFrames() {
113
+ const root = $('frames');
114
+ root.textContent = '';
115
+ const list = frames();
116
+ if (!list.length) root.appendChild(el('div', { class: 'empty', text: 'No extra frames for this status.' }));
117
+ list.forEach((f, i) => {
118
+ const update = (key, val) => {
119
+ const next = clone(frames());
120
+ if (val === undefined || val === '') delete next[i][key];
121
+ else next[i][key] = val;
122
+ setFrames(next);
123
+ changed();
124
+ };
125
+ root.appendChild(el('div', { class: 'frame-row' }, [
126
+ templateInput(f.details, 'Top line', 'Frame ' + (i + 1) + ' top line', (v) => update('details', v)),
127
+ templateInput(f.state, 'Bottom line', 'Frame ' + (i + 1) + ' bottom line', (v) => update('state', v)),
128
+ el('input', {
129
+ type: 'text', value: requiresText(f), placeholder: 'Only when…', autocomplete: 'off',
130
+ 'aria-label': 'Frame ' + (i + 1) + ' condition', title: 'Value name that must be non-empty, e.g. streak',
131
+ oninput: (e) => update('requires', parseRequires(e.target.value)),
132
+ }),
133
+ el('button', {
134
+ class: 'x', text: '×', 'aria-label': 'Remove frame ' + (i + 1),
135
+ onclick: () => { const next = clone(frames()); next.splice(i, 1); setFrames(next); renderFrames(); changed(); },
136
+ }),
137
+ ]));
138
+ });
139
+ }
140
+
141
+ function renderCard() {
142
+ renderTabs();
143
+ const b = statusBlock();
144
+ $('f-details').value = b.details || '';
145
+ $('f-state').value = b.state || '';
146
+ $('f-hover').value = b.largeImageText || '';
147
+ $('f-asset').value = (cfg.statusAssets || {})[status] || '';
148
+ renderFrames();
149
+ renderPreview();
150
+ }
151
+
152
+ // ── Discord section ────────────────────────────────────────────────────
153
+ function buttons() { return Array.isArray((cfg.presence || {}).buttons) ? cfg.presence.buttons : []; }
154
+ function setButtons(list) { cfg.presence = cfg.presence || {}; cfg.presence.buttons = list; }
155
+
156
+ function renderButtons() {
157
+ const root = $('buttons');
158
+ root.textContent = '';
159
+ const list = buttons();
160
+ if (!list.length) root.appendChild(el('div', { class: 'empty', text: 'No buttons.' }));
161
+ list.forEach((b, i) => {
162
+ const update = (key, val) => { const next = clone(buttons()); next[i][key] = val; setButtons(next); changed(); };
163
+ root.appendChild(el('div', { class: 'button-row' }, [
164
+ el('input', { type: 'text', value: b.label || '', placeholder: 'Label', 'aria-label': 'Button ' + (i + 1) + ' label', maxlength: 32, oninput: (e) => update('label', e.target.value) }),
165
+ el('input', { type: 'url', value: b.url || '', placeholder: 'https://…', 'aria-label': 'Button ' + (i + 1) + ' link', oninput: (e) => update('url', e.target.value.trim()) }),
166
+ el('button', { class: 'x', text: '×', 'aria-label': 'Remove button ' + (i + 1), onclick: () => { const next = clone(buttons()); next.splice(i, 1); setButtons(next); renderButtons(); changed(); } }),
167
+ ]));
168
+ });
169
+ $('add-button').disabled = list.length >= 2;
170
+ }
171
+
172
+ function renderForm() {
173
+ renderCard();
174
+ $('f-appName').value = cfg.appName || '';
175
+ $('f-clientId').value = cfg.clientId || '';
176
+ $('f-activityType').value = String(cfg.activityType == null ? 0 : cfg.activityType);
177
+ $('f-showElapsed').checked = cfg.showElapsed !== false;
178
+ $('f-githubButton').checked = (cfg.presence || {}).githubButton !== false;
179
+ renderButtons();
180
+ $('f-rotation').value = cfg.rotationIntervalMs == null ? '' : Math.round(cfg.rotationIntervalMs / 1000);
181
+ $('f-idle').value = cfg.idleThresholdSec == null ? '' : cfg.idleThresholdSec;
182
+ $('f-stale').value = cfg.staleSessionMin == null ? '' : cfg.staleSessionMin;
183
+ $('f-shipped').value = cfg.shippedFrameSec == null ? '' : cfg.shippedFrameSec;
184
+ $('f-hideWhenStale').checked = cfg.hideWhenStale !== false;
185
+ $('f-notify').checked = !!(cfg.notify && cfg.notify.enabled);
186
+ }
187
+
188
+ // ── form → cfg bindings ────────────────────────────────────────────────
189
+ function bind(id, apply, event) {
190
+ $(id).addEventListener(event || 'input', (e) => { apply(e.target); changed(); });
191
+ }
192
+ // A cleared text line is removed from the block, so the daemon uses its default.
193
+ const setOrDelete = (obj, key, val) => { if (val === '') delete obj[key]; else obj[key] = val; };
194
+ // A cleared number is removed too; a typed one is stored scaled (sec → ms).
195
+ const numOrDelete = (key, scale) => (t) => {
196
+ if (t.value === '' || !Number.isFinite(Number(t.value))) delete cfg[key];
197
+ else cfg[key] = Math.max(0, Number(t.value)) * (scale || 1);
198
+ };
199
+
200
+ function wire() {
201
+ bind('f-details', (t) => { setOrDelete(statusBlock(), 'details', t.value); renderPreview(); });
202
+ bind('f-state', (t) => { setOrDelete(statusBlock(), 'state', t.value); renderPreview(); });
203
+ bind('f-hover', (t) => setOrDelete(statusBlock(), 'largeImageText', t.value));
204
+ bind('f-asset', (t) => {
205
+ cfg.statusAssets = cfg.statusAssets || {};
206
+ setOrDelete(cfg.statusAssets, status, t.value.trim());
207
+ renderPreview();
208
+ });
209
+ bind('f-appName', (t) => { setOrDelete(cfg, 'appName', t.value.trim()); renderPreview(); });
210
+ bind('f-clientId', (t) => { cfg.clientId = t.value.trim(); });
211
+ bind('f-activityType', (t) => { cfg.activityType = Number(t.value) || 0; }, 'change');
212
+ bind('f-showElapsed', (t) => { cfg.showElapsed = t.checked; }, 'change');
213
+ bind('f-githubButton', (t) => { cfg.presence = cfg.presence || {}; cfg.presence.githubButton = t.checked; }, 'change');
214
+ bind('f-rotation', numOrDelete('rotationIntervalMs', 1000));
215
+ bind('f-idle', numOrDelete('idleThresholdSec'));
216
+ bind('f-stale', numOrDelete('staleSessionMin'));
217
+ bind('f-shipped', numOrDelete('shippedFrameSec'));
218
+ bind('f-hideWhenStale', (t) => { cfg.hideWhenStale = t.checked; }, 'change');
219
+ bind('f-notify', (t) => { cfg.notify = cfg.notify || {}; cfg.notify.enabled = t.checked; }, 'change');
220
+
221
+ $('add-frame').addEventListener('click', () => {
222
+ setFrames(clone(frames()).concat([{ details: '', state: '' }]));
223
+ renderFrames();
224
+ changed();
225
+ const rows = $('frames').querySelectorAll('.frame-row');
226
+ if (rows.length) rows[rows.length - 1].querySelector('input').focus();
227
+ });
228
+ $('add-button').addEventListener('click', () => {
229
+ if (buttons().length >= 2) return;
230
+ setButtons(clone(buttons()).concat([{ label: '', url: '' }]));
231
+ renderButtons();
232
+ changed();
233
+ const rows = $('buttons').querySelectorAll('.button-row');
234
+ rows[rows.length - 1].querySelector('input').focus();
235
+ });
236
+
237
+ // "Insert value" — drops {name} at the cursor of the last template line
238
+ // the user was in.
239
+ const noteTemplateInput = (e) => {
240
+ if (e.target.matches && e.target.matches('#f-details, #f-state, #f-hover, [data-template]')) lastTemplateInput = e.target;
241
+ };
242
+ document.addEventListener('focusin', noteTemplateInput);
243
+ document.addEventListener('input', noteTemplateInput);
244
+ $('var-pick').addEventListener('change', (e) => {
245
+ const name = e.target.value;
246
+ e.target.value = '';
247
+ const input = lastTemplateInput && document.contains(lastTemplateInput) ? lastTemplateInput : $('f-details');
248
+ if (!name) return;
249
+ const at = input.selectionStart == null ? input.value.length : input.selectionStart;
250
+ const end = input.selectionEnd == null ? at : input.selectionEnd;
251
+ input.value = input.value.slice(0, at) + '{' + name + '}' + input.value.slice(end);
252
+ input.focus();
253
+ input.setSelectionRange(at + name.length + 2, at + name.length + 2);
254
+ input.dispatchEvent(new Event('input', { bubbles: true }));
255
+ });
256
+
257
+ $('save').addEventListener('click', save);
258
+ $('revert').addEventListener('click', () => { cfg = clone(base); renderForm(); changed(); });
259
+ document.addEventListener('keydown', (e) => {
260
+ if ((e.ctrlKey || e.metaKey) && e.key === 's') { e.preventDefault(); if (dirty()) save(); }
261
+ });
262
+ window.addEventListener('beforeunload', (e) => { if (dirty()) { e.preventDefault(); e.returnValue = ''; } });
263
+
264
+ $('daemon-start').addEventListener('click', () => daemon('start'));
265
+ $('daemon-stop').addEventListener('click', () => daemon('stop'));
266
+ $('daemon-restart').addEventListener('click', () => daemon('restart'));
267
+ $('log-details').addEventListener('toggle', () => { if ($('log-details').open) refreshLog(); });
268
+ }
269
+
270
+ // ── save bar ───────────────────────────────────────────────────────────
271
+ const dirty = () => !!base && JSON.stringify(base) !== JSON.stringify(cfg);
272
+ let noticeTimer = null;
273
+
274
+ function bar(kind, msg) {
275
+ const b = $('savebar');
276
+ b.className = 'savebar' + (kind ? ' ' + kind : '');
277
+ $('save-msg').textContent = msg;
278
+ const editing = kind === '' || kind === 'err';
279
+ $('save').hidden = !editing || !dirty();
280
+ $('revert').hidden = !editing || !dirty();
281
+ b.hidden = false;
282
+ }
283
+ function changed() {
284
+ clearTimeout(noticeTimer);
285
+ if (dirty()) bar('', 'Unsaved changes');
286
+ else $('savebar').hidden = true;
287
+ }
288
+
289
+ // Rows the user added and left blank aren't settings — drop them rather
290
+ // than write empty frames/buttons into the file.
291
+ function pruneBlanks() {
292
+ for (const [name, block] of Object.entries((cfg.presence || {}).byStatus || {})) {
293
+ if (!Array.isArray(block.rotation)) continue;
294
+ storeFrames(block, name, block.rotation.filter((f) => f && (f.details || f.state)));
295
+ }
296
+ if (Array.isArray((cfg.presence || {}).buttons)) {
297
+ cfg.presence.buttons = cfg.presence.buttons.filter((b) => b && (b.label || b.url));
298
+ }
299
+ }
300
+
301
+ async function save() {
302
+ pruneBlanks();
303
+ $('save').disabled = true;
304
+ const r = await api('/api/settings', { base, edited: cfg });
305
+ $('save').disabled = false;
306
+ if (r.error) { bar('err', r.error); return; }
307
+ base = r.config;
308
+ cfg = clone(base);
309
+ renderForm();
310
+ bar('ok', 'Saved. The card updates within a few seconds.');
311
+ noticeTimer = setTimeout(() => { if (!dirty()) $('savebar').hidden = true; }, 3500);
312
+ }
313
+
314
+ // ── daemon ─────────────────────────────────────────────────────────────
315
+ function renderDaemon(d, note) {
316
+ const dot = $('daemon-dot');
317
+ let title, sub, cls;
318
+ if (!d.running) {
319
+ cls = 'down'; title = 'Stopped'; sub = 'Your Discord card is not being updated.';
320
+ } else if (d.ipc === 'up') {
321
+ cls = 'up'; title = 'Running · connected to Discord';
322
+ sub = d.client === 'arrpc' ? 'Through a bridge client (Vesktop, arRPC).' : 'pid ' + d.pid;
323
+ } else {
324
+ cls = 'wait'; title = 'Running · waiting for Discord';
325
+ sub = 'Open the Discord desktop app. It connects within about 15 seconds.';
326
+ }
327
+ dot.className = 'dot ' + cls;
328
+ $('daemon-title').textContent = title;
329
+ $('daemon-sub').textContent = note || sub;
330
+ $('daemon-start').disabled = d.running;
331
+ $('daemon-stop').disabled = !d.running;
332
+ $('daemon-restart').disabled = !d.running;
333
+ }
334
+
335
+ async function daemon(action) {
336
+ for (const id of ['daemon-start', 'daemon-stop', 'daemon-restart']) $(id).disabled = true;
337
+ $('daemon-title').textContent = action === 'stop' ? 'Stopping…' : action === 'start' ? 'Starting…' : 'Restarting…';
338
+ $('daemon-sub').textContent = '';
339
+ $('daemon-dot').className = 'dot wait';
340
+ const r = await api('/api/daemon', { action });
341
+ renderDaemon(r.daemon || { running: false }, r.error || '');
342
+ if (r.error) $('log-details').open = true;
343
+ if ($('log-details').open) refreshLog();
344
+ }
345
+
346
+ async function refreshLog() {
347
+ const r = await api('/api/log');
348
+ const pre = $('log');
349
+ pre.textContent = r.error ? r.error : (r.content || 'The log is empty.');
350
+ pre.scrollTop = pre.scrollHeight;
351
+ }
352
+
353
+ async function pollDaemon() {
354
+ if (document.hidden) return;
355
+ const r = await api('/api/settings');
356
+ if (r.error || !r.daemon) return;
357
+ renderDaemon(r.daemon);
358
+ live = r.live || live;
359
+ if (cfg) renderPreview();
360
+ }
361
+
362
+ // ── privacy ────────────────────────────────────────────────────────────
363
+ const LEVELS = [['public', 'Public'], ['name-only', 'Name only'], ['hidden', 'Hidden']];
364
+
365
+ async function loadWorkspaces() {
366
+ const root = $('workspaces');
367
+ const r = await api('/api/workspaces');
368
+ root.textContent = '';
369
+ if (r.error) { root.appendChild(el('div', { class: 'empty', text: r.error })); return; }
370
+ if (!r.workspaces.length) {
371
+ root.appendChild(el('div', { class: 'empty', text: 'No projects yet. Use Claude Code in a project and it will appear here.' }));
372
+ return;
373
+ }
374
+ for (const ws of r.workspaces) {
375
+ const current = r.visibility[ws.cwd] || 'public';
376
+ const seg = el('div', { class: 'seg', role: 'group', 'aria-label': 'Visibility of ' + ws.name });
377
+ for (const [level, label] of LEVELS) {
378
+ seg.appendChild(el('button', {
379
+ text: label, 'aria-pressed': String(level === current),
380
+ onclick: async (e) => {
381
+ const res = await api('/api/workspaces', { cwd: ws.cwd, level });
382
+ if (res.error) { bar('err', res.error); return; }
383
+ for (const b of seg.children) b.setAttribute('aria-pressed', String(b === e.target));
384
+ },
385
+ }));
386
+ }
387
+ root.appendChild(el('div', { class: 'ws-row' }, [
388
+ el('div', { class: 'ws-meta' }, [
389
+ el('div', { class: 'ws-name', text: ws.name }),
390
+ el('div', { class: 'ws-path', text: ws.cwd, title: ws.cwd }),
391
+ ]),
392
+ seg,
393
+ ]));
394
+ }
395
+ }
396
+
397
+ // ── boot ───────────────────────────────────────────────────────────────
398
+ async function boot() {
399
+ const r = await api('/api/settings');
400
+ if (r.error) {
401
+ $('load-error').textContent = r.error;
402
+ $('load-error').hidden = false;
403
+ return;
404
+ }
405
+ base = r.config;
406
+ cfg = clone(base);
407
+ live = r.live || {};
408
+ statuses = r.statuses || ['working', 'idle'];
409
+ status = statuses[0];
410
+ const pick = $('var-pick');
411
+ for (const v of r.vars || []) pick.appendChild(el('option', { value: v, text: v }));
412
+ $('config-path').textContent = r.configPath;
413
+ $('version').textContent = 'v' + r.version;
414
+ wire();
415
+ renderForm();
416
+ renderDaemon(r.daemon);
417
+ loadWorkspaces();
418
+ setInterval(pollDaemon, 5000);
419
+ }
420
+
421
+ boot();
422
+ })();
@@ -0,0 +1,145 @@
1
+ /* /settings — layered on dashboard.css (tokens, .page, .topbar, .brand). */
2
+
3
+ .settings .page { max-width: 860px; padding-bottom: 140px; }
4
+ .settings .topbar { margin-bottom: 28px; }
5
+
6
+ .set-card {
7
+ background: #fff; border: 2px solid var(--ink); box-shadow: var(--shadow);
8
+ padding: 22px 24px 24px; margin-bottom: 28px;
9
+ }
10
+ .set-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
11
+ .set-head h2 { font-family: var(--font-disp); font-size: 20px; font-weight: 700; }
12
+ .sub-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 22px 0 10px; padding-top: 18px; border-top: 2px dashed var(--paper-dark); }
13
+ .sub-head h3 { font-family: var(--font-mono); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
14
+ .set-hint { font-size: 13px; color: var(--ink-mute); }
15
+ .set-error {
16
+ background: #fff; border: 2px solid var(--rust); color: var(--rust);
17
+ padding: 12px 16px; margin-bottom: 24px; font-weight: 600;
18
+ }
19
+
20
+ /* Buttons */
21
+ .btn {
22
+ font-family: var(--font-mono); font-size: 12px; font-weight: 700;
23
+ padding: 8px 14px; background: #fff; color: var(--ink);
24
+ border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
25
+ transition: transform 0.1s, box-shadow 0.1s;
26
+ }
27
+ .btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
28
+ .btn:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
29
+ .btn:disabled { opacity: 0.4; cursor: default; }
30
+ .btn.primary { background: var(--ink); color: var(--paper); box-shadow: 2px 2px 0 var(--rust); }
31
+ .btn.primary:hover:not(:disabled) { box-shadow: 3px 3px 0 var(--rust); }
32
+ .btn.ghost { border-style: dashed; box-shadow: none; color: var(--ink-mute); margin-top: 10px; }
33
+ .btn.ghost:hover:not(:disabled) { color: var(--ink); box-shadow: none; transform: none; border-style: solid; }
34
+ .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
35
+ .settings :focus-visible { outline: 3px solid var(--rust); outline-offset: 2px; }
36
+
37
+ /* Daemon */
38
+ .daemon-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
39
+ .daemon-text { flex: 1; min-width: 200px; }
40
+ .daemon-title { font-weight: 700; font-size: 15px; }
41
+ .daemon-sub { font-size: 13px; color: var(--ink-mute); }
42
+ .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper-dark); flex: none; }
43
+ .dot.up { background: var(--grass); }
44
+ .dot.wait { background: var(--tape); }
45
+ .dot.down { background: var(--rust); }
46
+ .log { margin-top: 16px; }
47
+ .log summary { font-family: var(--font-mono); font-size: 12px; font-weight: 700; cursor: pointer; color: var(--ink-mute); width: fit-content; }
48
+ .log pre {
49
+ margin-top: 10px; max-height: 260px; overflow: auto;
50
+ background: var(--ink); color: var(--paper); padding: 12px 14px;
51
+ font-family: var(--font-mono); font-size: 11.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
52
+ }
53
+
54
+ /* Segmented control (status tabs, privacy levels) */
55
+ .seg { display: inline-flex; flex-wrap: wrap; border: 2px solid var(--ink); background: #fff; }
56
+ .seg button {
57
+ font-family: var(--font-mono); font-size: 12px; font-weight: 700;
58
+ padding: 7px 12px; border-right: 2px solid var(--ink); color: var(--ink-mute);
59
+ }
60
+ .seg button:last-child { border-right: none; }
61
+ .seg button:hover { color: var(--ink); background: var(--paper); }
62
+ .seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--tape); color: var(--ink); }
63
+
64
+ /* Card preview — shaped like the Discord activity row */
65
+ .preview {
66
+ display: grid; grid-template-columns: 64px 1fr; gap: 16px; align-items: center;
67
+ margin: 18px 0; padding: 16px; background: var(--paper); border: 2px dashed var(--ink-mute);
68
+ min-height: 100px;
69
+ }
70
+ .preview .avatar { width: 64px; height: 64px; background: var(--paper-dark); border: 2px solid var(--ink); overflow: hidden; }
71
+ .preview .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
72
+ .pv-text { min-width: 0; }
73
+ .pv-app { font-weight: 700; font-size: 14px; }
74
+ .pv-details, .pv-state { font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
75
+ .pv-state { color: var(--ink-mute); }
76
+
77
+ /* Fields */
78
+ .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
79
+ .grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 18px; }
80
+ .field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-mute); min-width: 0; }
81
+ .settings input[type="text"], .settings input[type="number"], .settings input[type="url"], .settings select {
82
+ font: inherit; font-size: 14px; font-weight: 400; color: var(--ink);
83
+ background: #fff; border: 2px solid var(--ink); padding: 8px 10px; width: 100%; min-width: 0;
84
+ border-radius: 0;
85
+ }
86
+ .settings input::placeholder { color: var(--ink-faint); }
87
+ .unit { display: flex; align-items: center; gap: 8px; font-weight: 400; }
88
+ .unit input { width: 90px; }
89
+ .checks { display: flex; flex-direction: column; gap: 8px; justify-content: flex-end; }
90
+ .checks.row { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 10px 28px; margin-top: 18px; }
91
+ .check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
92
+ .check input { width: 16px; height: 16px; accent-color: var(--ink); }
93
+
94
+ /* Insert-a-value picker */
95
+ .insert { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; font-weight: 600; color: var(--ink-mute); }
96
+ .insert select { width: auto; max-width: 220px; padding: 5px 8px; font-size: 13px; }
97
+ .insert code { font-family: var(--font-mono); background: var(--paper); padding: 1px 5px; border: 1px solid var(--paper-dark); }
98
+
99
+ /* Repeating rows: extra frames, buttons */
100
+ .rowlist { display: grid; gap: 8px; }
101
+ .frame-row, .button-row { display: grid; gap: 8px; align-items: center; }
102
+ .frame-row { grid-template-columns: 1fr 1fr 150px 34px; margin-bottom: 8px; }
103
+ .button-row { grid-template-columns: 1fr 1.6fr 34px; margin-bottom: 8px; }
104
+ .x {
105
+ width: 34px; height: 38px; font-size: 18px; line-height: 1; color: var(--ink-mute);
106
+ border: 2px solid transparent;
107
+ }
108
+ .x:hover { color: var(--rust); border-color: var(--rust); }
109
+ .empty { font-size: 13px; color: var(--ink-faint); padding: 4px 0; }
110
+
111
+ /* Privacy */
112
+ .ws-row { display: flex; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--paper-dark); }
113
+ .ws-row:last-child { border-bottom: none; }
114
+ .ws-meta { flex: 1; min-width: 0; }
115
+ .ws-name { font-weight: 700; }
116
+ .ws-path { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
117
+
118
+ .settings footer { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-mute); }
119
+
120
+ /* Save bar */
121
+ .savebar {
122
+ position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
123
+ display: flex; align-items: center; gap: 10px;
124
+ background: var(--tape); border: 2px solid var(--ink); box-shadow: var(--shadow);
125
+ padding: 10px 12px 10px 16px; max-width: calc(100vw - 32px); z-index: 10;
126
+ }
127
+ .savebar[hidden] { display: none; }
128
+ .save-msg { font-weight: 600; font-size: 13px; margin-right: 6px; }
129
+ .savebar.ok { background: #fff; }
130
+ .savebar.err { background: #fff; border-color: var(--rust); }
131
+ .savebar.err .save-msg { color: var(--rust); }
132
+
133
+ @media (max-width: 640px) {
134
+ .settings .page { padding: 20px 16px 140px; }
135
+ .set-card { padding: 16px; }
136
+ .grid2 { grid-template-columns: 1fr; }
137
+ .frame-row { grid-template-columns: 1fr 34px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--paper-dark); }
138
+ .frame-row input { grid-column: 1; }
139
+ .frame-row .x { grid-column: 2; grid-row: 1; }
140
+ .button-row { grid-template-columns: 1fr 34px; }
141
+ .button-row input { grid-column: 1; }
142
+ .button-row .x { grid-column: 2; grid-row: 1; }
143
+ .ws-row { flex-direction: column; align-items: stretch; gap: 8px; }
144
+ }
145
+ @media (prefers-reduced-motion: reduce) { .btn { transition: none; } }