@coda-console/friends 0.3.0 → 0.4.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,106 @@
1
+ // 头像裁剪:本地选的图放进 1:1 方框,拖动平移(Pointer Events,鼠标与触控都走它)、滑块缩放 1.0×–3.0×,
2
+ // 导出 512×512 的压缩图。图片只经 URL.createObjectURL 读进来,换图、清除时回收地址。
3
+ import { BLOB_MAX_BYTES } from '../lib/avatar.mjs';
4
+ import { h } from './dom.mjs';
5
+
6
+ export const OUTPUT_SIZE = 512;
7
+ const VIEW = 440, MIN_ZOOM = 1, MAX_ZOOM = 3;
8
+ const clamp = (value, low, high) => Math.min(high, Math.max(low, value));
9
+ const toBlob = (canvas, type, quality) => new Promise(resolve => canvas.toBlob(resolve, type, quality));
10
+
11
+ /** 先试 WebP 0.86;浏览器不会编 WebP(退回别的格式或给 null)或超限,就用 JPEG 0.86,仍超限降到 0.72。 */
12
+ export async function encodeAvatar(canvas) {
13
+ const webp = await toBlob(canvas, 'image/webp', 0.86);
14
+ if (webp?.type === 'image/webp' && webp.size <= BLOB_MAX_BYTES) return webp;
15
+ for (const quality of [0.86, 0.72]) {
16
+ const jpeg = await toBlob(canvas, 'image/jpeg', quality);
17
+ if (jpeg && jpeg.size <= BLOB_MAX_BYTES) return jpeg;
18
+ }
19
+ throw new Error('图片压缩后仍超过 5 MiB,请换一张');
20
+ }
21
+
22
+ /** onChange 在画面变化(载入、拖动、缩放、清除)后调用,给实时预览用。 */
23
+ export function createCropper({ onChange } = {}) {
24
+ let crop = null, url = null, drag = null, loading = 0;
25
+ const canvas = h('canvas', { class: 'crop-canvas', width: VIEW, height: VIEW });
26
+ const zoomText = h('span', { class: 'mono zoom-value' }, '1.0×');
27
+ const zoom = h('input', { type: 'range', min: MIN_ZOOM, max: MAX_ZOOM, step: '0.01', value: '1', 'aria-label': '缩放',
28
+ oninput: e => { if (crop) { crop.zoom = clamp(Number(e.target.value), MIN_ZOOM, MAX_ZOOM); draw(); } } });
29
+ const box = h('div', { class: 'crop-box', role: 'img', 'aria-label': '拖动调整头像位置',
30
+ onpointerdown: e => {
31
+ if (!crop) return;
32
+ box.setPointerCapture(e.pointerId);
33
+ drag = { id: e.pointerId, x: e.clientX, y: e.clientY, ox: crop.x, oy: crop.y, ratio: VIEW / (box.clientWidth || VIEW) };
34
+ box.className = 'crop-box dragging';
35
+ },
36
+ onpointermove: e => {
37
+ if (!drag || e.pointerId !== drag.id) return;
38
+ crop.x = drag.ox + (e.clientX - drag.x) * drag.ratio;
39
+ crop.y = drag.oy + (e.clientY - drag.y) * drag.ratio;
40
+ draw();
41
+ },
42
+ onpointerup: end, onpointercancel: end,
43
+ }, canvas, h('div', { class: 'crop-grid', 'aria-hidden': 'true' }));
44
+ function end() { drag = null; box.className = 'crop-box'; }
45
+
46
+ // 图按「铺满方框」缩放后再乘 zoom;平移限制在不露出空白的范围里。
47
+ function layout(size) {
48
+ const { img } = crop, scale = Math.max(size / img.naturalWidth, size / img.naturalHeight) * crop.zoom;
49
+ const width = img.naturalWidth * scale, height = img.naturalHeight * scale;
50
+ return { scale, width, height, x: (size - width) / 2 + crop.x * (size / VIEW), y: (size - height) / 2 + crop.y * (size / VIEW) };
51
+ }
52
+ function draw() {
53
+ const ctx = canvas.getContext('2d');
54
+ ctx.clearRect(0, 0, VIEW, VIEW);
55
+ if (crop) {
56
+ const { width, height } = layout(VIEW);
57
+ crop.x = clamp(crop.x, -(width - VIEW) / 2, (width - VIEW) / 2);
58
+ crop.y = clamp(crop.y, -(height - VIEW) / 2, (height - VIEW) / 2);
59
+ const at = layout(VIEW);
60
+ ctx.drawImage(crop.img, at.x, at.y, at.width, at.height);
61
+ zoomText.textContent = `${crop.zoom.toFixed(1)}×`;
62
+ }
63
+ onChange?.();
64
+ }
65
+
66
+ // 换一张:先回收上一张的地址;读的途中又换了或清除了,就不再用这张。
67
+ async function load(file) {
68
+ clear();
69
+ const mine = ++loading, img = new Image();
70
+ url = URL.createObjectURL(file);
71
+ try {
72
+ await new Promise((resolve, reject) => { img.onload = resolve; img.onerror = () => reject(new Error('读不出这张图片,请换一张')); img.src = url; });
73
+ } catch (e) { if (mine === loading) clear(); throw e; }
74
+ if (mine !== loading) return false;
75
+ crop = { img, zoom: MIN_ZOOM, x: 0, y: 0 };
76
+ zoom.value = String(MIN_ZOOM);
77
+ draw();
78
+ return true;
79
+ }
80
+ function reset() {
81
+ if (!crop) return;
82
+ Object.assign(crop, { zoom: MIN_ZOOM, x: 0, y: 0 });
83
+ zoom.value = String(MIN_ZOOM);
84
+ draw();
85
+ }
86
+ function clear() {
87
+ loading++;
88
+ if (url) URL.revokeObjectURL(url);
89
+ url = null; crop = null; drag = null;
90
+ box.className = 'crop-box';
91
+ zoom.value = String(MIN_ZOOM); zoomText.textContent = '1.0×';
92
+ draw();
93
+ }
94
+ // 方框里看到的部分画到 512×512 上(先铺白底,JPEG 没有透明);画面在调用时就定下,之后再换图不影响这次导出。
95
+ function exportBlob() {
96
+ const out = document.createElement('canvas');
97
+ out.width = OUTPUT_SIZE; out.height = OUTPUT_SIZE;
98
+ const ctx = out.getContext('2d'), at = layout(OUTPUT_SIZE);
99
+ ctx.fillStyle = '#fff';
100
+ ctx.fillRect(0, 0, OUTPUT_SIZE, OUTPUT_SIZE);
101
+ ctx.drawImage(crop.img, at.x, at.y, at.width, at.height);
102
+ return encodeAvatar(out);
103
+ }
104
+
105
+ return { box, canvas, zoom, zoomText, load, reset, clear, export: exportBlob, get ready() { return Boolean(crop); } };
106
+ }
package/view/dom.mjs ADDED
@@ -0,0 +1,22 @@
1
+ // 好友页建节点的小工具:只用 DOM API(createElement / createElementNS / textContent),不拼 HTML。
2
+ const SVG_NS = 'http://www.w3.org/2000/svg';
3
+
4
+ const present = children => children.flat().filter(c => c !== null && c !== undefined && c !== false);
5
+
6
+ function build(node, attrs, children) {
7
+ for (const [key, value] of Object.entries(attrs ?? {})) {
8
+ if (value === undefined || value === null || value === false) continue;
9
+ if (key.startsWith('on')) node.addEventListener(key.slice(2), value); else node.setAttribute(key, value === true ? '' : value);
10
+ }
11
+ node.append(...present(children));
12
+ return node;
13
+ }
14
+
15
+ /** replaceChildren,但跳过 null / undefined / false(原生的会把它们当文字插进去)。 */
16
+ export const fill = (node, ...children) => node.replaceChildren(...present(children));
17
+ export const h = (tag, attrs = {}, ...children) => build(document.createElement(tag), attrs, children);
18
+ export const svg = (tag, attrs = {}, ...children) => build(document.createElementNS(SVG_NS, tag), attrs, children);
19
+
20
+ /** 5×5 几何纹(identiconPattern 的格子)画成矢量 SVG,颜色随 currentColor。 */
21
+ export const identiconSvg = grid => svg('svg', { viewBox: '-1 -1 7 7', 'shape-rendering': 'crispEdges', 'aria-hidden': 'true' },
22
+ grid.flatMap((row, r) => row.map((on, c) => (on ? svg('rect', { x: c, y: r, width: 1, height: 1, fill: 'currentColor' }) : null))));
package/view/style.css CHANGED
@@ -1,61 +1,208 @@
1
- /* 好友页:只用 App 给的 --coda-* 变量,手机优先。 */
1
+ /* 好友页「活的极客名片 · Bento」:颜色只取 App 给的 --coda-* 变量(带回退),手机优先,>= 680px 宽屏。 */
2
2
  :root {
3
+ color-scheme: light dark;
4
+ --fg: var(--coda-foreground, CanvasText);
5
+ --fg2: var(--coda-secondary, #6e6e73);
6
+ --fg3: var(--coda-tertiary, #8e8e93);
7
+ --bg: var(--coda-background, Canvas);
8
+ --card: var(--coda-card, color-mix(in srgb, var(--fg) 4%, var(--bg)));
9
+ --fill: var(--coda-fill, rgba(120, 120, 128, .12));
10
+ --line: var(--coda-separator, rgba(120, 120, 128, .24));
11
+ --accent: var(--coda-accent, #0a84ff);
12
+ --green: var(--coda-green, #34c759);
13
+ --orange: var(--coda-orange, #ff9500);
14
+ --red: var(--coda-red, #ff3b30);
15
+ --mono: var(--coda-mono, ui-monospace, Menlo, monospace);
3
16
  font: var(--coda-font-size, 13px)/1.45 var(--coda-font, -apple-system, system-ui, sans-serif);
4
- color: var(--coda-foreground, #1d1d1f); background: transparent;
17
+ color: var(--fg); background: transparent;
5
18
  }
6
19
  * { box-sizing: border-box; }
20
+ [hidden] { display: none !important; }
7
21
  html, body { margin: 0; }
8
22
  button, input, select, textarea { font: inherit; color: inherit; }
9
23
  button { cursor: pointer; }
10
24
  button:disabled { opacity: .5; cursor: default; }
11
- :focus-visible { outline: 2px solid var(--coda-accent, #0a84ff); outline-offset: 2px; border-radius: 6px; }
25
+ :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
12
26
  .selectable { -webkit-user-select: text; user-select: text; }
13
- .mono { font-family: var(--coda-mono, ui-monospace, Menlo, monospace); font-size: .92em; }
14
- .secondary { color: var(--coda-secondary, #6e6e73); }
27
+ .mono { font-family: var(--mono); font-size: .92em; }
28
+ .secondary { color: var(--fg2); }
15
29
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
16
30
  .spacer { flex: 1 1 auto; }
31
+ .center { text-align: center; }
17
32
 
18
- .page { max-width: 760px; margin: 0 auto; padding: 12px 16px 24px; }
19
- section { margin-top: 20px; }
20
- section:first-child { margin-top: 0; }
21
- h2 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 1em; font-weight: 600; }
22
- .count { padding: 0 6px; border-radius: 8px; font-size: .85em; background: var(--coda-fill, rgba(120, 120, 128, .12)); color: var(--coda-secondary, #6e6e73); }
23
- .card { padding: 12px; border-radius: var(--coda-radius-card, 12px); background: var(--coda-card, rgba(120, 120, 128, .08)); border: 1px solid var(--coda-separator, rgba(60, 60, 67, .18)); display: flex; flex-direction: column; gap: 10px; }
24
- .hint { margin: 0; color: var(--coda-secondary, #6e6e73); font-size: .92em; }
25
- .error { margin: 0; color: var(--coda-red, #ff3b30); overflow-wrap: anywhere; }
26
- .ok { margin: 0; color: var(--coda-green, #34c759); }
27
- .progress { margin: 0; color: var(--coda-secondary, #6e6e73); }
28
- .empty { margin: 0; color: var(--coda-secondary, #6e6e73); }
29
-
33
+ .page { max-width: 760px; margin: 0 auto; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
34
+ .hint, .progress, .empty { margin: 0; color: var(--fg2); font-size: .92em; }
35
+ .error { margin: 0; color: var(--red); overflow-wrap: anywhere; }
36
+ .ok { margin: 0; color: var(--green); overflow-wrap: anywhere; }
30
37
  .line { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
31
- label.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 140px; min-width: 0; }
32
- label.field > span { color: var(--coda-secondary, #6e6e73); font-size: .92em; }
33
- input, select, textarea { width: 100%; min-width: 0; padding: 7px 9px; border-radius: var(--coda-radius, 8px); border: 1px solid var(--coda-separator, rgba(60, 60, 67, .18)); background: var(--coda-background, transparent); }
38
+ .line.nowrap { flex-wrap: nowrap; }
39
+ .stack { display: flex; flex-direction: column; gap: 12px; }
40
+ .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
41
+ .actions.split { padding-top: 12px; border-top: 1px solid var(--line); }
42
+ .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
43
+ .lbl { display: block; color: var(--fg2); font-size: .88em; font-weight: 600; }
44
+ .fields { display: flex; flex-wrap: wrap; gap: 10px; }
45
+ .fields > .field { flex: 1 1 140px; }
46
+ input, textarea { width: 100%; min-width: 0; padding: 8px 10px; border-radius: var(--coda-radius, 9px); border: 1px solid var(--line); background: var(--bg); outline: none; }
47
+ input:focus, textarea:focus { border-color: var(--accent); }
34
48
  textarea { min-height: 84px; resize: vertical; }
35
- .btn { padding: 7px 14px; border-radius: var(--coda-radius, 8px); border: 0; font-weight: 600; background: var(--coda-accent, #0a84ff); color: #fff; }
36
- .btn.quiet { background: var(--coda-fill, rgba(120, 120, 128, .12)); color: var(--coda-foreground, #1d1d1f); }
37
- .btn.danger { background: color-mix(in srgb, var(--coda-red, #ff3b30) 14%, transparent); color: var(--coda-red, #ff3b30); }
38
- .btn.small { padding: 3px 10px; font-weight: 500; font-size: .92em; }
39
- details > summary { cursor: pointer; color: var(--coda-secondary, #6e6e73); }
49
+ input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--fg); }
50
+ details > summary { cursor: pointer; color: var(--fg2); }
40
51
  details[open] > summary { margin-bottom: 10px; }
41
- .fields { display: flex; flex-wrap: wrap; gap: 10px; }
42
52
 
43
- .identity { align-items: center; }
44
- .key { font-weight: 600; }
45
- .swatches { display: flex; gap: 8px; flex-wrap: wrap; }
46
- .swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
47
- .swatch[aria-pressed="true"] { border-color: var(--coda-foreground, #1d1d1f); }
48
-
49
- .list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--coda-separator, rgba(60, 60, 67, .18)); }
50
- .row { padding: 10px 0; border-bottom: 1px solid var(--coda-separator, rgba(60, 60, 67, .18)); display: flex; flex-direction: column; gap: 6px; }
51
- .avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 1.25em; font-weight: 600; color: #fff; }
52
- .who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
53
- .title { font-weight: 600; }
54
- .badge { padding: 1px 7px; border-radius: 6px; font-size: .88em; white-space: nowrap; background: var(--coda-fill, rgba(120, 120, 128, .12)); color: var(--coda-secondary, #6e6e73); }
55
- .badge.bound { background: color-mix(in srgb, var(--coda-green, #34c759) 16%, transparent); color: var(--coda-green, #34c759); }
56
- .badge.pending { background: color-mix(in srgb, var(--coda-orange, #ff9500) 16%, transparent); color: var(--coda-orange, #ff9500); }
57
- .badge.conflict { background: color-mix(in srgb, var(--coda-red, #ff3b30) 16%, transparent); color: var(--coda-red, #ff3b30); }
58
- .actions { display: flex; gap: 8px; flex-wrap: wrap; }
59
- .c-blue { background: var(--coda-blue, #0a84ff); } .c-orange { background: var(--coda-orange, #ff9500); } .c-green { background: var(--coda-green, #34c759); }
60
- .c-purple { background: var(--coda-purple, #af52de); } .c-pink { background: var(--coda-pink, #ff2d55); } .c-teal { background: var(--coda-teal, #30b0c7); }
61
- .c-gray { background: var(--coda-tertiary, #8e8e93); }
53
+ .btn { padding: 7px 14px; border-radius: var(--coda-radius, 9px); border: 0; font-weight: 600; background: var(--accent); color: #fff; white-space: nowrap; }
54
+ .btn.quiet { background: var(--fill); color: var(--fg); }
55
+ .btn.danger { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
56
+ .btn.small { padding: 4px 11px; font-weight: 550; font-size: .92em; }
57
+
58
+ /* 主题色:每个色类给出 --c,再派生柔和底色与前景色,浅/深色都跟着背景走。 */
59
+ .c-blue { --c: var(--coda-blue, #0a84ff); } .c-orange { --c: var(--coda-orange, #ff9500); } .c-green { --c: var(--coda-green, #34c759); }
60
+ .c-purple { --c: var(--coda-purple, #af52de); } .c-pink { --c: var(--coda-pink, #ff2d55); } .c-teal { --c: var(--coda-teal, #30b0c7); }
61
+ .c-gray { --c: var(--coda-gray, #8e8e93); }
62
+ .c-blue, .c-orange, .c-green, .c-purple, .c-pink, .c-teal, .c-gray {
63
+ --c-soft: color-mix(in srgb, var(--c) 16%, var(--bg));
64
+ --c-ink: color-mix(in srgb, var(--c) 78%, var(--fg));
65
+ }
66
+
67
+ /* 多机切换条 */
68
+ .machines { display: flex; gap: 6px; flex-wrap: wrap; }
69
+ .m-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border: 0; border-radius: 8px; background: var(--fill); color: var(--fg2); font-size: .92em; font-weight: 550; }
70
+ .m-pill[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
71
+ .m-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
72
+ .m-dot.off { background: var(--fg3); }
73
+ .m-why { font-size: .85em; color: var(--fg3); }
74
+
75
+ /* 点阵柔光渐变 Banner */
76
+ .banner { position: relative; height: 84px;
77
+ background:
78
+ radial-gradient(circle at 88% -10%, color-mix(in srgb, var(--c) 34%, transparent), transparent 55%),
79
+ linear-gradient(125deg, color-mix(in srgb, var(--c) 12%, var(--bg)) 0%, color-mix(in srgb, var(--c) 30%, var(--bg)) 55%, color-mix(in srgb, var(--c) 52%, var(--bg)) 100%); }
80
+ .banner::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
81
+ background-image: radial-gradient(color-mix(in srgb, var(--bg) 70%, transparent) 1px, transparent 1.5px); background-size: 14px 14px; }
82
+ .banner.small { height: 60px; }
83
+ .banner-acts { position: absolute; top: 12px; right: 12px; z-index: 1; display: flex; gap: 6px; }
84
+ .pill { height: 28px; padding: 0 12px; border: 0; border-radius: 999px; font-size: .92em; font-weight: 600; color: var(--fg);
85
+ background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
86
+ .pill.strong { background: var(--fg); color: var(--bg); }
87
+
88
+ /* 跨界方圆头像 */
89
+ .av { display: grid; place-items: center; overflow: hidden; flex: none; background: var(--c-soft, var(--fill)); color: var(--c-ink, var(--fg)); font-weight: 700; line-height: 1; }
90
+ .av img, .av svg, .av canvas { width: 100%; height: 100%; display: block; object-fit: cover; }
91
+ .av.k-identicon svg { padding: 6%; }
92
+ .av.lg { width: 100%; height: 100%; border-radius: 17px; font-size: 30px; }
93
+ .av.lg.k-emoji { font-size: 36px; }
94
+ .av.md { width: 100%; height: 100%; border-radius: 14px; font-size: 24px; }
95
+ .av.sm { width: 44px; height: 44px; border-radius: 13px; font-size: 18px; }
96
+ .av.sm.k-emoji { font-size: 22px; }
97
+ .av-ring { position: relative; flex: none; display: block; width: 78px; height: 78px; padding: 3.5px; border: 0; border-radius: 22px; background: var(--bg); box-shadow: 0 4px 14px rgba(0, 0, 0, .14); }
98
+ .av-ring.md { width: 62px; height: 62px; padding: 3px; border-radius: 18px; }
99
+ .av-ring.lg { width: 70px; height: 70px; }
100
+ button.av-ring { transition: transform .14s ease; }
101
+ button.av-ring:active:not(:disabled) { transform: scale(.96); }
102
+ .cam { position: absolute; right: -4px; bottom: -4px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--fg); color: var(--bg); border: 2.5px solid var(--bg); }
103
+
104
+ /* Hero 名片卡 */
105
+ .hero { border-radius: 22px; border: 1px solid var(--line); background: var(--bg); overflow: hidden; box-shadow: 0 8px 24px rgba(0, 0, 0, .06); }
106
+ .hero-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
107
+ .hero-id { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
108
+ .hero-id > .av-ring { margin-top: -46px; position: relative; z-index: 1; }
109
+ .hero-names { min-width: 0; padding-bottom: 2px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
110
+ .name-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
111
+ .hero-name { margin: 0; font-size: 1.6em; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
112
+ .tag { padding: 2px 7px; border-radius: 6px; background: var(--c-soft); color: var(--c-ink); font-size: .82em; font-weight: 600; white-space: nowrap; }
113
+ .fp { padding: 3px 8px; border: 0; border-radius: 8px; background: var(--fill); color: var(--fg2); font-size: .85em; }
114
+
115
+ /* Bento 状态条 */
116
+ .bento { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
117
+ .tile { min-width: 0; padding: 9px 11px; border-radius: 13px; border: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; gap: 2px; }
118
+ .tile-k { font-size: .78em; font-weight: 600; letter-spacing: .04em; color: var(--fg3); }
119
+ .tile-v { display: flex; align-items: center; gap: 6px; font-weight: 650; min-width: 0; }
120
+ .tile-s { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; font-size: .88em; color: var(--fg2); min-width: 0; }
121
+ .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
122
+ .ok-dot { background: var(--green); } .warn-dot { background: var(--orange); } .off-dot { background: var(--fg3); }
123
+
124
+ /* 好友列表 */
125
+ .sec { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 1em; font-weight: 650; color: var(--fg2); }
126
+ .count { padding: 0 7px; border-radius: 999px; font-size: .85em; background: var(--fill); font-variant-numeric: tabular-nums; }
127
+ .friends { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
128
+ .f-tile { position: relative; width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); text-align: left; overflow: hidden; }
129
+ .f-tile::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); opacity: .7; }
130
+ .f-tile:active { transform: scale(.99); }
131
+ .f-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
132
+ .f-name { font-weight: 650; font-size: 1.05em; }
133
+ .f-meta { font-family: var(--mono); font-size: .85em; color: var(--fg3); }
134
+ .badge { flex: none; padding: 1px 7px; border-radius: 6px; font-size: .85em; font-weight: 550; white-space: nowrap; background: var(--fill); color: var(--fg2); }
135
+ .badge.bound { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
136
+ .badge.pending { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
137
+ .badge.conflict { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
138
+ .empty { padding: 22px 16px; text-align: center; border: 1px dashed var(--line); border-radius: 14px; }
139
+
140
+ /* 弹层:窄屏底部抽屉,宽屏居中模态;只罩住页面可见的部分(document 框架给出 visible-top / visible-height)。 */
141
+ .scrim { position: absolute; left: 0; right: 0; top: var(--coda-visible-top, 0); height: var(--coda-visible-height, 100%); z-index: 20;
142
+ display: flex; align-items: flex-end; justify-content: center; background: color-mix(in srgb, #000 34%, transparent); }
143
+ .dialog { width: 100%; max-height: calc(100% - 24px); display: flex; flex-direction: column; overflow: hidden;
144
+ background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 40px rgba(0, 0, 0, .22); }
145
+ .grabber { flex: none; width: 36px; height: 5px; margin: 7px auto 0; border-radius: 3px; background: color-mix(in srgb, var(--fg) 22%, transparent); }
146
+ .dlg-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px 10px; border-bottom: 1px solid var(--line); }
147
+ .dlg-head h3 { margin: 0; font-size: 1.12em; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
148
+ .dlg-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; }
149
+ .dlg-body:last-child { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
150
+ .dlg-foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
151
+
152
+ /* 迷你名片(编辑预览、好友详情) */
153
+ .mini-card { border-radius: 18px; border: 1px solid var(--line); background: var(--bg); overflow: hidden; }
154
+ .mini-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 6px; }
155
+ .mini-body > .av-ring { margin-top: -30px; z-index: 1; }
156
+ .mini-body.row { flex-direction: row; align-items: flex-end; gap: 12px; }
157
+ .mini-body.row > .av-ring { margin-top: -34px; }
158
+ .mini-names { flex: 1 1 auto; min-width: 0; padding-bottom: 2px; }
159
+ .mini-name { font-size: 1.25em; font-weight: 700; }
160
+
161
+ /* 编辑名片 */
162
+ .ed-cols { display: grid; gap: 16px; }
163
+ .ed-controls { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
164
+ .seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 2px; border-radius: 9px; background: var(--fill); }
165
+ .seg button { height: 28px; border: 0; border-radius: 7px; background: none; color: var(--fg2); font-size: .92em; font-weight: 550; }
166
+ .seg button[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
167
+ .pane { display: flex; flex-direction: column; gap: 8px; }
168
+ .crop-box { position: relative; width: min(240px, 100%); aspect-ratio: 1; margin: 0 auto; border-radius: 18px; overflow: hidden; cursor: grab; touch-action: none;
169
+ -webkit-user-select: none; user-select: none; background: color-mix(in srgb, var(--fg) 88%, var(--bg)); box-shadow: 0 6px 20px rgba(0, 0, 0, .16); }
170
+ .crop-box.dragging { cursor: grabbing; }
171
+ .crop-canvas { display: block; width: 100%; height: 100%; }
172
+ .crop-grid { position: absolute; inset: 0; pointer-events: none; border-radius: 18px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85); opacity: .75;
173
+ background:
174
+ linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255, 255, 255, .35) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgba(255, 255, 255, .35) 0 calc(66.66% + .5px), transparent 0),
175
+ linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255, 255, 255, .35) 0 calc(33.33% + .5px), transparent 0 calc(66.66% - .5px), rgba(255, 255, 255, .35) 0 calc(66.66% + .5px), transparent 0);
176
+ transition: opacity .15s; }
177
+ .crop-box:not(.dragging) .crop-grid { background: none; }
178
+ .zoom-row { display: flex; align-items: center; gap: 8px; font-size: .9em; }
179
+ .zoom-row input { flex: 1 1 auto; }
180
+ .zoom-value { min-width: 3.2em; text-align: right; color: var(--fg2); }
181
+ .emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
182
+ .emoji-opt { aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; border: 2px solid transparent; background: var(--card); font-size: 1.4em; padding: 0; }
183
+ .emoji-opt[aria-pressed="true"] { border-color: var(--fg); }
184
+ .swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; max-width: 280px; }
185
+ .swatch { aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; padding: 0; background: var(--c); box-shadow: inset 0 0 0 2px var(--bg); }
186
+ .swatch[aria-pressed="true"] { border-color: var(--fg); }
187
+
188
+ /* 好友详情 */
189
+ .facts { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; align-items: baseline; }
190
+ .facts dt { color: var(--fg2); font-size: .92em; }
191
+ .facts dd { margin: 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
192
+ .key-full { overflow-wrap: anywhere; word-break: break-all; }
193
+ .warn-box { margin: 0 0 8px; padding: 9px 11px; border-radius: 11px; background: color-mix(in srgb, var(--red) 11%, transparent); color: var(--red); font-size: .92em; }
194
+
195
+ @media (min-width: 680px) {
196
+ .page { padding: 18px 24px 28px; gap: 20px; }
197
+ .hero-body { padding: 14px 20px 18px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); align-items: end; column-gap: 18px; }
198
+ .hero-body > .hint, .hero-body > .ok, .hero-body > .error, .hero-body > .progress { grid-column: 1 / -1; }
199
+ .hero-body > .bento { grid-row: 1; grid-column: 2; }
200
+ .hero-id { align-self: start; }
201
+ .friends { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
202
+ .scrim { align-items: center; padding: 20px; }
203
+ .dialog { max-width: 560px; max-height: calc(100% - 40px); border-radius: 14px; box-shadow: 0 22px 60px rgba(0, 0, 0, .26); }
204
+ .grabber { display: none; }
205
+ .dlg-head { padding-top: 12px; }
206
+ .dlg-body:last-child, .dlg-foot { padding-bottom: 12px; }
207
+ .ed-cols { grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
208
+ }