cortico-world-bottle 0.5.0 → 0.6.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +40 -0
  3. package/dist/webui-3f345722d940.js +392 -0
  4. package/dist/webui-521a0aabc302.css +97 -0
  5. package/dist/webui.css +52 -0
  6. package/dist/webui.js +222 -3
  7. package/package.json +9 -4
  8. package/world/card-host.ps1 +5 -2
  9. package/world/card-sound.ps1 +42 -0
  10. package/world/card.ts +3 -2
  11. package/world/config.ts +152 -73
  12. package/world/definition.ts +4 -0
  13. package/world/lan.ts +138 -0
  14. package/world/page-sound.ts +121 -0
  15. package/world/page-style.ts +20 -1
  16. package/world/page-view.ts +14 -1
  17. package/world/page.ts +30 -15
  18. package/world/sound.ts +71 -0
  19. package/world/sounds/README.md +27 -0
  20. package/world/sounds/incoming/New_notifications_1.wav +0 -0
  21. package/world/sounds/incoming/New_notifications_2.wav +0 -0
  22. package/world/sounds/incoming/New_notifications_3.wav +0 -0
  23. package/world/sounds/incoming/New_notifications_4.wav +0 -0
  24. package/world/sounds/incoming/New_notifications_5.wav +0 -0
  25. package/world/sounds/incoming/memes_michael-jackson-hee-hee.wav +0 -0
  26. package/world/sounds/incoming/memes_rockstone.wav +0 -0
  27. package/world/sounds/incoming/memes_taco-bell-bong.wav +0 -0
  28. package/world/sounds/incoming/memes_/345/221/246/345/220/274_cut.wav +0 -0
  29. package/world/sounds/incoming/memes_/345/245/266/351/276/231/345/244/247/347/254/221_cut.wav +0 -0
  30. package/world/sounds/incoming/memes_/347/206/212/345/244/247/346/212/275/350/261/241/347/254/221/345/243/260_cut.wav +0 -0
  31. package/world/sounds/reply/New_notifications_1.wav +0 -0
  32. package/world/sounds/reply/New_notifications_2.wav +0 -0
  33. package/world/sounds/reply/New_notifications_3.wav +0 -0
  34. package/world/sounds/reply/New_notifications_4.wav +0 -0
  35. package/world/sounds/reply/New_notifications_5.wav +0 -0
  36. package/world/sounds/reply/memes_michael-jackson-hee-hee.wav +0 -0
  37. package/world/sounds/reply/memes_rockstone.wav +0 -0
  38. package/world/sounds/reply/memes_taco-bell-bong.wav +0 -0
  39. package/world/sounds/reply/memes_/345/221/246/345/220/274_cut.wav +0 -0
  40. package/world/sounds/reply/memes_/345/245/266/351/276/231/345/244/247/347/254/221_cut.wav +0 -0
  41. package/world/sounds/reply/memes_/347/206/212/345/244/247/346/212/275/350/261/241/347/254/221/345/243/260_cut.wav +0 -0
  42. package/world/store.ts +17 -0
  43. package/world/wake.ts +3 -3
  44. package/world/world.ts +112 -36
  45. package/dist/webui-26d5711404e0.js +0 -173
  46. package/dist/webui-913b85a5c54c.css +0 -45
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.6.0 · 把信箱带在身边
4
+
5
+ **2026-11-02**
6
+
7
+ - 手机也能翻信了:开启其他设备访问,扫码配对后即可使用;默认关闭,HTTP 访问会提醒明文风险。
8
+ - 来信和收到的回信新增「尚未阅读/已读 X 次」,一起读信时也会告诉桌宠这是第几次重读。
9
+ - 新增来信、回信提示音,附有抽象音效;可选包内声音或本机文件,调整音量与淡出,桌面和网页独立设置。
10
+ - 手机等其他设备发起写信、打捞、回信或重写,不再唤起 Windows 卡片;电脑正常通知不受影响。
11
+ - 配置页按用途分类,扫码区域更清楚;修复音效列表混用,只有根目录的「通用」音效会同时出现在两类列表。
12
+
3
13
  ## 0.5.0 · 海边信箱大更新
4
14
 
5
15
  **重要更新 · 2026-11-02**
package/README.md CHANGED
@@ -38,6 +38,32 @@ Coo 写一封不超过 120 字的信。**寄不寄,由你决定**;别人家
38
38
 
39
39
  World 顶部按「可寄/可捞/可回」显示今日剩余额度;状态灯随额度变化(大于 1 为绿,1 为黄,0 为灰,网络异常为红)。信箱页端口的说明提示「叫它帮你打开信箱。」;也可以使用「信箱」页签中的「打开信箱」按钮。
40
40
 
41
+ ## 在手机或其他设备上看信(可选)
42
+
43
+ 在 World 扩展的「信箱」页签找到「把信箱带在身边」,开启「允许其他设备访问」并保存,然后重启漂流瓶 World。默认另外监听 `0.0.0.0:7798`,原来的 `127.0.0.1` 入口、桌面卡片与让桌宠打开信箱的方式不变。
44
+
45
+ 点击「显示配对二维码」,用手机扫描可达地址的二维码;配对后浏览器保存 Cookie,正常重启无需重新配对。Cookie 有效期一年,清理浏览器数据或点击「重置配对」后需要重新扫码。重置会立即撤销所有旧配对。二维码在本机生成,不经过第三方服务;它相当于信箱钥匙,请勿分享。
46
+
47
+ - 同一局域网:通常直接使用卡片列出的网卡地址;多张网卡时选择手机可达的一项,需要放行此端口的防火墙规则。
48
+ - 服务器或端口映射:填写「对外访问地址」,例如 `http://主机地址:7798/`,并自行开放端口。**允许裸 HTTP 端口直连,但信件和配对凭据会明文传输,界面以红字提醒,风险由使用者承担。**
49
+ - HTTPS 反向代理:填写 `https://信箱域名/`,将这个域名的根路径代理到对外监听,并保留原始 `Host` 和 `Origin`;HTTPS 配对 Cookie 带 `Secure`。仅支持独立域名根路径,不支持子路径挂载。请勿把无鉴权的回环监听代理到公网。
50
+
51
+ 配对令牌通过 `ctx.secret()` / `ctx.storeSecret()` 存入部署的 `BOTTLE_LAN_PAIRING_TOKEN`,不写进普通配置、信件、日志或模型上下文。所有对外信箱路由都需要配对,写操作还校验同源与信箱请求头;正文仍只在你点了「回信」或「一起读信」后进入桌宠上下文。
52
+
53
+ 这一功能只改扩展,不需要修改 Coopanion 内核或漂流瓶中央服务端。网络配置不会自动替你修改。对外监听无法启动时会在卡片说明原因,本机信箱仍可使用。
54
+
55
+ ## 阅读标记与信箱声音
56
+
57
+ 信册中的来信、群岛来信与收到的回信显示阅读标记:黄色「尚未阅读」或绿色「已读 X 次」。次数记录的是成功把信递给桌宠的动作:点「回信」授权读信,或点「一起读信」;只在网页展开正文不增加次数。一起读收到的回信时,会附上原信作为上下文,但只增加回信的阅读次数。寄出的信无法单独一起读,因此不计阅读次数,只显示「还在漂」等信件状态。「一起读信」会带上「这是你们第 X 次读这封信」。记录保存在本机信册,重启保留;旧信没有历史计数,从 0 开始,不追算。
58
+
59
+ Windows 卡片的新来信与回信使用不同的提示音,在 World「配置」页分别选择音效包、本机音效文件或静音。桌面总开关默认开启,音量默认 70%,末尾淡出默认 250 毫秒,可设为 0—5000 毫秒。草稿卡片、等待卡片不响铃,卡片关闭也会停止声音;文件无法读取或格式不受系统支持时安静跳过。Windows 建议使用 WAV / MP3,每个文件不超过 10MB。旧版本内置 `default.wav` 选择会更新为本类新默认值,有效的自选音效、本机文件和静音偏好不会被覆盖。
60
+
61
+ 音效包来信目录为 `world/sounds/incoming/`,默认使用 `New_notifications_1.wav`;回信目录为 `world/sounds/reply/`,默认使用 `New_notifications_3.wav`。两个列表各自只显示对应子目录的音频,不再互混。**要让同一音频供来信和回信共用,请将文件直接放在两个子目录同级的 `world/sounds/` 根目录**,列表会标为「通用」。只扫描直接文件,不扫描更深层目录或其他子目录;同名文件也按所在目录区分。配置页重新打开下拉、网页刷新后即可看到新文件,详见 [音效包说明](world/sounds/README.md)。升级扩展可能替换安装目录,请先备份自己添加的文件,或使用单独存放的本机文件。
62
+
63
+ 其他设备的网页里,展开「信箱声音 · 本设备」,先点「启用声音」,再分别选择来信与回信的声音、音量和淡出。浏览器的设置与文件只留在当前设备;选中的文件保存到 IndexedDB,不上传电脑或服务器。每次打开页面先把已有信件作为基线,之后新出现的来信、回信各提醒一次,轮询和刷新不会重复响。浏览器需要先有点击操作,页面关闭或设备休眠时不保证提醒。本机回环网页在原生卡片模式下避免重复播放。
64
+
65
+ 从对外入口发起的写信、打捞、回信及重写不会唤起 Windows 卡片,等待桌宠写完后也留在网页中;本机发起的操作与独立到达的后台回信仍保留原来的桌面提醒。只是打开一个手机页面不会全局关闭电脑通知。本次阅读标记和音效均在扩展内实现,无需修改 Coopanion 内核或中央服务端配置。
66
+
41
67
  ## 客户端构成
42
68
 
43
69
  `world/client.ts` 负责服务端协议,`store.ts` 保存本机草稿与信册,`world.ts` 连接工具、事件及人工确认;`page.ts` 管理本机 HTTP 路由,`page-view.ts` 管理网页结构和交互,`page-style.ts` 管理视觉样式。Windows 卡片由 `cards.ts`、`card.ts` 与 `card-host.ps1` 负责。
@@ -46,12 +72,23 @@ World 顶部按「可寄/可捞/可回」显示今日剩余额度;状态
46
72
 
47
73
  ## 配置
48
74
 
75
+ 原生「配置」页按「显示与通知 → 海边邀请与提醒 → 桌面音效 → 来信提示音 → 回信提示音 → 其他设备访问 → 连接与调试」排列。来信、回信的声音分别先选来源,再设置对应的包内音效或本机文件。仅调整分组与顺序,原有配置键、数值与默认值不变;修改地址、端口的重启要求也不变。
76
+
49
77
  | 键 | 说明 |
50
78
  |---|---|
51
79
  | `worlds.bottle.server` | 信漂去的那片海。改地址要重启 World。 |
52
80
  | `worlds.bottle.port` | 本机页面端口,被占用时顺延。「打开信箱」按钮会使用实际启动的地址。 |
81
+ | `worlds.bottle.lanEnabled` | 其他设备访问开关,默认关闭,修改后重启 World。 |
82
+ | `worlds.bottle.lanPort` | 独立对外端口,默认 7798;占用时报错,不自动顺延。 |
83
+ | `worlds.bottle.lanPublicUrl` | 可选对外地址;留空列出网卡地址,支持 HTTP/HTTPS 根路径,修改后重启 World。 |
53
84
  | `worlds.bottle.randomWake` | 自动海边邀请与待办提醒,默认开启;独立信箱和信箱页签可分别暂停、恢复或调整间隔。 |
54
85
  | `worlds.bottle.cardAutoCloseSec` | 卡片自动收起秒数,默认 10,0 为不自动收起;下一张卡片生效。 |
86
+ | `worlds.bottle.soundEnabled` | Windows 新来信/回信提示音总开关,默认开启。 |
87
+ | `worlds.bottle.soundVolume` | 桌面提示音音量,0—100,默认 70。 |
88
+ | `worlds.bottle.soundFadeOutMs` | 桌面提示音末尾淡出,0—5000 毫秒,默认 250。 |
89
+ | `worlds.bottle.soundIncomingSource` / `soundReplySource` | 各类声音来源:`pack` 音效包、`local` 本机文件、`off` 静音。 |
90
+ | `worlds.bottle.soundIncomingPack` / `soundReplyPack` | 包内音效,如 `incoming/New_notifications_1.wav`、`reply/New_notifications_3.wav`。 |
91
+ | `worlds.bottle.soundIncomingFile` / `soundReplyFile` | 来源选 `local` 时使用的本机音频绝对路径。 |
55
92
  | `worlds.bottle.surface` | `auto` / `card`(只用卡片)/ `page`(只用网页)。 |
56
93
  | `worlds.bottle.tsunamiNotice` | 海啸提示开关;关掉只是不让 Coo 被打扰。 |
57
94
  | `worlds.bottle.debug` | 开发者模式:只记 id 与数量,不记信件内容。 |
@@ -97,3 +134,6 @@ MIT。
97
134
  信箱页脚的「想对毛球说…」会打开一张小反馈便笺:可跳转 GitHub 新建 Issue,或在「Coo 的家长群」1~5 群直接 @会动的毛球。弹窗只是入口说明,不采集信件、日志,也不自动提交任何内容。浏览器标签图标与页眉图片均读取扩展自带的 `world/icon.png`,不需要远程图床。
98
135
 
99
136
  若部署中保存过自定义环境提示词,需在提示词编辑页合并新版表达自由与自主延后说明,避免旧规则继续覆盖包内默认模板。
137
+
138
+
139
+ 开发时更新面板后,除构建测试外,还需核对真实宿主:`pnpm check:running-webui -- http://127.0.0.1:<框架端口>`。若运行资源已更新但旧设置窗口仍看不到新卡片,刷新设置页;仅切换页签不会重新加载模块。若命令提示宿主仍登记旧资源,则完整重启 Coopanion 后再刷新。详见 [面板加载排查](docs/design/webui-loading.md)。
@@ -0,0 +1,392 @@
1
+ /** Only HTTP(S) mailbox roots supplied by this World may be opened. */
2
+ export function mailboxUrl(value) {
3
+ if (typeof value !== 'string')
4
+ return null;
5
+ try {
6
+ const url = new URL(value);
7
+ return ['http:', 'https:'].includes(url.protocol) &&
8
+ !url.username && !url.password && url.pathname === '/' && !url.search && !url.hash
9
+ ? url.href : null;
10
+ }
11
+ catch {
12
+ return null;
13
+ }
14
+ }
15
+ export function reachableMailbox(links, hostname) {
16
+ const urls = links.map(link => mailboxUrl(link.href)).filter((url) => !!url);
17
+ const local = (host) => ['127.0.0.1', 'localhost', '[::1]'].includes(host);
18
+ if (!hostname || local(hostname))
19
+ return urls.find(url => local(new URL(url).hostname)) ?? urls[0] ?? null;
20
+ return urls.find(url => new URL(url).hostname === hostname) ?? urls.find(url => !local(new URL(url).hostname)) ?? null;
21
+ }
22
+ export async function mountMailbox(ctx) {
23
+ const zh = ctx.language === 'zh' || ctx.language === 'zh-Hant';
24
+ const t = zh ? {
25
+ title: '去信箱看看',
26
+ description: '写好的信、捞到的来信和等来的回音,都收在这里。',
27
+ open: '打开信箱', loading: '正在找信箱…',
28
+ unavailable: '信箱暂时没有打开,请重启漂流瓶 World 后再试。',
29
+ error: '暂时没找到信箱,请稍后再试。', ready: '在浏览器中打开,寄不寄仍由你决定。',
30
+ } : {
31
+ title: 'Visit your mailbox', description: 'Your drafts, found letters and replies are waiting here.',
32
+ open: 'Open mailbox', loading: 'Finding your mailbox…',
33
+ unavailable: 'The mailbox is not running. Restart the Bottle World and try again.',
34
+ error: 'Could not find the mailbox. Please try again shortly.',
35
+ ready: 'Opens in your browser. You still decide whether to send each letter.',
36
+ };
37
+ const ui = ctx.ui;
38
+ const card = ui.h('section', 'bottle-mailbox-entry');
39
+ const copy = ui.h('div', 'bottle-mailbox-copy');
40
+ copy.append(ui.h('h2', null, t.title), ui.h('p', null, t.description));
41
+ let url = null;
42
+ const button = ui.button(t.open, { variant: 'primary', onClick: () => {
43
+ if (url && !ctx.signal.aborted)
44
+ ctx.root.ownerDocument.defaultView?.open(url, '_blank', 'noopener,noreferrer');
45
+ } });
46
+ button.classList.add('bottle-open-mailbox');
47
+ button.disabled = true;
48
+ const note = ui.h('p', 'bottle-mailbox-note', t.loading);
49
+ card.append(copy, button, note);
50
+ ctx.root.append(card);
51
+ const invitations = ui.h('section', 'bottle-wake-controls');
52
+ invitations.append(ui.h('h3', null, zh ? '海边的邀请' : 'Seaside invitations'));
53
+ const controls = ['write', 'catch', 'remind'].map(action => {
54
+ const row = ui.h('div', 'bottle-wake-row');
55
+ const label = ui.h('span');
56
+ const toggle = ui.button(zh ? '稍等' : 'Loading', { onClick: () => { void changeWake(action); } });
57
+ toggle.disabled = true;
58
+ const hoursLabel = ui.h('label', 'bottle-wake-interval', zh ? '最短间隔(小时)' : 'Minimum interval (hours)');
59
+ const hours = ui.h('input');
60
+ hours.type = 'number';
61
+ hours.min = '2';
62
+ hours.max = '24';
63
+ hours.step = '1';
64
+ hours.value = '2';
65
+ hoursLabel.append(hours);
66
+ const save = ui.button(zh ? '调整' : 'Apply', { onClick: () => {
67
+ const value = Number(hours.value);
68
+ if (!Number.isFinite(value) || value < 2 || value > 24) {
69
+ outcome.textContent = zh ? '请填写 2—24 小时。' : 'Enter 2–24 hours.';
70
+ return;
71
+ }
72
+ void changeWake(action, value);
73
+ } });
74
+ row.append(label, hoursLabel, save, toggle);
75
+ invitations.append(row);
76
+ return { action, label, toggle, hours, save };
77
+ });
78
+ invitations.append(ui.h('p', 'bottle-wake-outcome', zh ? '实际时刻在最短间隔的 1—2 倍内随机,最长 24 小时;每类每天最多 3 次。配置页顶栏为快照,信箱页签每 5 秒同步。' : 'Random timing: 1–2× the minimum, capped at 24 hours; at most 3 per type daily. Header snapshots sync every 5 seconds on this tab.'));
79
+ const outcome = ui.h('p', 'bottle-wake-outcome');
80
+ invitations.append(outcome);
81
+ ctx.root.append(invitations);
82
+ let wake = null;
83
+ let changing = false;
84
+ async function changeWake(action, hours) {
85
+ if (!wake || changing || ctx.signal.aborted)
86
+ return;
87
+ changing = true;
88
+ controls.forEach(item => { item.toggle.disabled = true; item.save.disabled = true; });
89
+ const lane = wake.lanes[action];
90
+ try {
91
+ const result = await ctx.invoke('wake', hours === undefined
92
+ ? [action, lane.paused || lane.declined || lane.failed ? 'resume' : 'pause'] : [action, 'interval', hours]);
93
+ if (result?.ok === false)
94
+ throw new Error(result.message);
95
+ if (!ctx.signal.aborted)
96
+ await refresh();
97
+ }
98
+ catch {
99
+ if (!ctx.signal.aborted)
100
+ outcome.textContent = zh ? '暂时没能保存,请稍后再试。' : 'Could not save. Please retry.';
101
+ }
102
+ finally {
103
+ changing = false;
104
+ if (!ctx.signal.aborted)
105
+ controls.forEach(item => { item.toggle.disabled = !wake?.lanes[item.action]; item.save.disabled = !wake?.lanes[item.action]; });
106
+ }
107
+ }
108
+ function renderWake() {
109
+ controls.forEach(({ action, label, toggle, hours, save }) => {
110
+ const lane = wake?.lanes[action];
111
+ const name = action === 'write' ? (zh ? '写信邀请' : 'Writing') : action === 'catch' ? (zh ? '打捞邀请' : 'Catching') : (zh ? '待办提醒' : 'Reminders');
112
+ label.textContent = name + (lane ? (zh ? ' · 今天邀请 ' + lane.count + ' 次' : ' · ' + lane.count + ' today') : '');
113
+ toggle.textContent = lane?.paused || lane?.declined || lane?.failed ? (zh ? '恢复邀请' : 'Resume') : (zh ? '暂停邀请' : 'Pause');
114
+ toggle.disabled = !lane || changing;
115
+ save.disabled = !lane || changing;
116
+ if (ctx.root.ownerDocument.activeElement !== hours)
117
+ hours.value = String(lane?.intervalHours ?? 2);
118
+ });
119
+ const last = wake?.history.at(-1);
120
+ const labels = zh ? {
121
+ completed: '已经处理', deferred: '它选择暂不做', declined: '今天不再邀请', paused: '已按人的选择暂停',
122
+ uncompleted: '这一轮没有结果,将有限重试', failed: '重试后仍未完成,今天不再邀请', cancelled: '条件变化,已取消', interrupted: '重启中断,已延后',
123
+ } : { completed: 'Completed', deferred: 'Deferred by the bot', declined: 'Declined for today', paused: 'Paused by the human',
124
+ uncompleted: 'No result; one bounded retry', failed: 'Retry exhausted; stopped for today', cancelled: 'Conditions changed', interrupted: 'Interrupted by restart; delayed' };
125
+ const active = wake?.active;
126
+ if (active) {
127
+ outcome.textContent = active.phase === 'retry'
128
+ ? (zh ? '上一轮没有结果,稍后只补试一次。' : 'No result in the last turn; one retry is scheduled.')
129
+ : (zh ? '已有一份邀请在等它选择,写不写、捞不捞都由它。' : 'One invitation is pending. The bot may still decline.');
130
+ return;
131
+ }
132
+ const result = last?.result === 'deferred' && last.reason === 'no_idea' ? (zh ? '它暂时没有灵感,已选择暂不做;不算失败,也不补试' : 'No inspiration right now; voluntarily deferred, not a failure or retry') : last?.reason === 'reminder_delivered' ? (zh ? '提醒已送达,是否询问由它决定' : 'Reminder delivered; the bot chooses whether to ask') : last?.reason === 'queue_failed' ? (zh ? '邀请未能送达,今天不再尝试' : 'Could not deliver; stopped for today') : last ? (labels[last.result] ?? last.result) : '';
133
+ outcome.textContent = last ? (zh ? (last.action === 'write' ? '最近的写信邀请:' : last.action === 'catch' ? '最近的打捞邀请:' : '最近的待办提醒:') : 'Last result: ') + result
134
+ : (zh ? '有想说或想听的时候再做,小感受也值得写;不必为邀请勉强。' : 'An invitation, not an obligation. No letter is better than filler.');
135
+ }
136
+ // Pairing is a separate human-only surface. Keep one selected QR visible.
137
+ const lanCard = ui.h('section', 'bottle-lan-card');
138
+ const lanHeader = ui.h('header', 'bottle-lan-header');
139
+ const lanIntro = ui.h('div');
140
+ lanIntro.append(ui.h('h3', null, zh ? '把信箱带在身边' : 'Take your mailbox with you'), ui.h('p', null, zh ? '手机扫一次码,就能随时翻信、确认寄出。' : 'Scan once to read letters and approve sending on your phone.'));
141
+ const lanBadge = ui.h('span', 'bottle-lan-badge');
142
+ lanHeader.append(lanIntro, lanBadge);
143
+ const lanBody = ui.h('div', 'bottle-lan-body');
144
+ const settings = ui.h('section', 'bottle-lan-settings');
145
+ settings.append(ui.h('h4', null, zh ? '访问设置' : 'Access settings'));
146
+ const enabledLabel = ui.h('label', 'bottle-lan-toggle');
147
+ const enabled = ui.h('input');
148
+ enabled.type = 'checkbox';
149
+ enabledLabel.append(enabled, ui.h('span', null, zh ? '允许其他设备访问' : 'Allow other devices'));
150
+ const portLabel = ui.h('label', 'bottle-lan-field', zh ? '对外端口' : 'External port');
151
+ const port = ui.h('input');
152
+ port.type = 'number';
153
+ port.min = '1';
154
+ port.max = '65535';
155
+ port.value = '7798';
156
+ portLabel.append(port);
157
+ const addressLabel = ui.h('label', 'bottle-lan-field', zh ? '对外地址 · 可选' : 'Public address · optional');
158
+ const address = ui.h('input');
159
+ address.type = 'url';
160
+ address.placeholder = 'http://192.168.1.10:7798/';
161
+ addressLabel.append(address);
162
+ let lanDirty = false, lanBusy = false, resetArmed = false;
163
+ for (const input of [enabled, port, address])
164
+ input.oninput = () => { lanDirty = true; };
165
+ let lan;
166
+ let pairingCards = [];
167
+ let addressKey = '';
168
+ let actionNote = '';
169
+ const saveLan = ui.button(zh ? '保存访问设置' : 'Save access settings', { onClick: () => { void saveAccess(); } });
170
+ saveLan.classList.add('bottle-lan-save');
171
+ settings.append(enabledLabel, portLabel, addressLabel, ui.h('p', 'bottle-lan-help', zh ? '同一网络下通常留空;服务器部署时,填写手机可达的地址。' : 'Usually leave blank on the same network. For a server, enter an address reachable from your phone.'), saveLan, ui.h('p', 'bottle-lan-help', zh ? '保存后重启漂流瓶 World 生效。本机入口不受影响。' : 'Restart Bottle World after saving. Local access stays available.'));
172
+ const pairing = ui.h('section', 'bottle-lan-pairing');
173
+ pairing.append(ui.h('h4', null, zh ? '设备配对' : 'Pair a device'));
174
+ const pickLabel = ui.h('label', 'bottle-lan-field', zh ? '手机可达的地址' : 'Address reachable from your phone');
175
+ const pick = ui.h('select');
176
+ pickLabel.append(pick);
177
+ const qrList = ui.h('div', 'bottle-lan-qr-list');
178
+ const lanActions = ui.h('div', 'bottle-lan-actions');
179
+ const pairButton = ui.button(zh ? '显示配对二维码' : 'Show pairing QR code', { variant: 'primary', onClick: () => {
180
+ if (pairingCards.length) {
181
+ pairingCards = [];
182
+ drawPairing();
183
+ return;
184
+ }
185
+ void showPairing(false);
186
+ } });
187
+ pairButton.classList.add('bottle-lan-reveal');
188
+ const resetButton = ui.button(zh ? '重置配对' : 'Reset pairing', { onClick: () => {
189
+ if (!resetArmed) {
190
+ resetArmed = true;
191
+ resetButton.textContent = zh ? '确认让旧配对失效' : 'Confirm revocation';
192
+ return;
193
+ }
194
+ void showPairing(true);
195
+ } });
196
+ pairButton.disabled = true;
197
+ resetButton.disabled = true;
198
+ lanActions.append(pairButton, resetButton);
199
+ const lanNote = ui.h('p', 'bottle-lan-feedback');
200
+ lanNote.setAttribute('role', 'status');
201
+ pairing.append(pickLabel, qrList, lanActions, lanNote);
202
+ lanBody.append(settings, pairing);
203
+ const footer = ui.h('footer', 'bottle-lan-footer');
204
+ footer.append(ui.h('p', 'bottle-lan-warning', zh
205
+ ? 'HTTP 裸端口会明文传输信件与配对凭据,使用风险需自行承担;公网建议使用 HTTPS。二维码是信箱钥匙,请勿分享。'
206
+ : 'HTTP sends letters and pairing credentials unencrypted, at your own risk. Use HTTPS on public networks. Keep your QR code private.'), ui.h('p', 'bottle-lan-help', zh ? '服务器需自行放行端口;这里不会改动防火墙或端口映射。' : 'Allow the port on your server. Firewall and port forwarding are not changed automatically.'));
207
+ lanCard.append(lanHeader, lanBody, footer);
208
+ ctx.root.append(lanCard);
209
+ pick.onchange = () => { actionNote = ''; drawPairing(); };
210
+ function drawPairing() {
211
+ qrList.replaceChildren();
212
+ const item = pairingCards.find(item => new URL(item.url).origin === new URL(pick.value || 'http://localhost').origin);
213
+ if (item) {
214
+ const figure = ui.h('figure', 'bottle-lan-qr');
215
+ const img = ui.h('img');
216
+ img.src = item.qr;
217
+ img.alt = zh ? '手机信箱配对二维码' : 'Mailbox pairing QR code';
218
+ img.width = img.height = 224;
219
+ const caption = ui.h('figcaption', null, zh ? '用手机扫码,配对后会记住这台设备' : 'Scan with your phone. This device will be remembered.');
220
+ const linkDetails = ui.h('details', 'bottle-lan-link');
221
+ const link = ui.h('input');
222
+ link.type = 'text';
223
+ link.readOnly = true;
224
+ link.value = item.url;
225
+ link.setAttribute('aria-label', zh ? '配对链接(请勿分享)' : 'Private pairing link');
226
+ link.onclick = () => link.select();
227
+ linkDetails.append(ui.h('summary', null, zh ? '查看配对链接' : 'View pairing link'), link);
228
+ figure.append(img, caption, linkDetails);
229
+ qrList.append(figure);
230
+ }
231
+ else {
232
+ const empty = ui.h('div', 'bottle-lan-empty');
233
+ empty.append(ui.h('span', null, zh ? '让信箱陪你走远一点' : 'Keep your mailbox close'), ui.h('p', null, lan?.running ? (zh ? '选好地址,再显示二维码' : 'Choose an address, then show the QR code') : (zh ? '开启访问并重启 World 后,即可扫码' : 'Enable access and restart World to pair')));
234
+ qrList.append(empty);
235
+ }
236
+ pairButton.textContent = pairingCards.length ? (zh ? '收起二维码' : 'Hide QR code') : (zh ? '显示配对二维码' : 'Show pairing QR code');
237
+ lanNote.textContent = actionNote;
238
+ }
239
+ function renderLan() {
240
+ pairButton.disabled = !lan?.running || !lan.urls.length || lanBusy;
241
+ resetButton.disabled = !lan?.running || lanBusy;
242
+ if (!lanDirty) {
243
+ enabled.checked = lan?.enabled ?? false;
244
+ port.value = String(lan?.port ?? 7798);
245
+ address.value = lan?.publicUrl ?? '';
246
+ }
247
+ lanBadge.textContent = lan?.error ? (zh ? '暂不可用' : 'Unavailable') : lan?.running ? (zh ? '已开启' : 'Listening') : (zh ? '未开启' : 'Off');
248
+ lanNote.textContent = lan?.error || actionNote || (lan?.enabled && !lan.running ? (zh ? '等待重启 World 后生效。' : 'Restart World to apply.') : '');
249
+ const urls = lan?.urls ?? [];
250
+ const key = JSON.stringify(urls);
251
+ if (key !== addressKey) {
252
+ const previous = pick.value;
253
+ addressKey = key;
254
+ pairingCards = [];
255
+ pick.replaceChildren();
256
+ for (const href of urls) {
257
+ const option = ui.h('option', null, href);
258
+ option.value = href;
259
+ pick.append(option);
260
+ }
261
+ if (!urls.length) {
262
+ const option = ui.h('option', null, zh ? '尚无可用地址' : 'No address available');
263
+ option.value = '';
264
+ pick.append(option);
265
+ }
266
+ pick.value = urls.includes(previous) ? previous : urls.find(href => href === lan?.publicUrl || /^http:\/\/(192\.168\.|10\.|172\.(1[6-9]|2\d|3[01])\.)/.test(href)) ?? urls[0] ?? '';
267
+ drawPairing();
268
+ }
269
+ pick.disabled = !lan?.running || !urls.length || lanBusy;
270
+ if (!lan?.running && pairingCards.length) {
271
+ pairingCards = [];
272
+ drawPairing();
273
+ }
274
+ lanNote.textContent = lan?.error || actionNote || (lan?.enabled && !lan.running ? (zh ? '等待重启 World 后生效。' : 'Restart World to apply.') : '');
275
+ }
276
+ async function saveAccess() {
277
+ if (lanBusy || ctx.signal.aborted)
278
+ return;
279
+ const value = Number(port.value), publicUrl = address.value.trim(), allow = enabled.checked;
280
+ if (!Number.isInteger(value) || value < 1 || value > 65535 || value === 7797 || (publicUrl && !mailboxUrl(publicUrl))) {
281
+ actionNote = zh ? '请检查端口(1—65535,避开 7797)和对外地址(仅支持 HTTP/HTTPS 根路径)。' : 'Check the port and HTTP/HTTPS root address.';
282
+ lanNote.textContent = actionNote;
283
+ return;
284
+ }
285
+ lanBusy = true;
286
+ saveLan.disabled = true;
287
+ renderLan();
288
+ try {
289
+ await ctx.setConfig('world:bottle', { 'worlds.bottle.lanEnabled': allow, 'worlds.bottle.lanPort': value, 'worlds.bottle.lanPublicUrl': publicUrl });
290
+ if (!ctx.signal.aborted) {
291
+ lanDirty = false;
292
+ pairingCards = [];
293
+ actionNote = zh ? '已保存,请重启漂流瓶 World 后扫码。' : 'Saved. Restart Bottle World, then scan.';
294
+ drawPairing();
295
+ }
296
+ }
297
+ catch {
298
+ if (!ctx.signal.aborted) {
299
+ actionNote = zh ? '未能保存,请稍后重试。' : 'Could not save. Please retry.';
300
+ lanNote.textContent = actionNote;
301
+ }
302
+ }
303
+ finally {
304
+ lanBusy = false;
305
+ if (!ctx.signal.aborted) {
306
+ saveLan.disabled = false;
307
+ renderLan();
308
+ }
309
+ }
310
+ }
311
+ async function showPairing(reset) {
312
+ if (lanBusy || !lan?.running || ctx.signal.aborted)
313
+ return;
314
+ lanBusy = true;
315
+ pairingCards = [];
316
+ actionNote = zh ? '正在准备配对码…' : 'Preparing a pairing code…';
317
+ drawPairing();
318
+ renderLan();
319
+ try {
320
+ const result = await ctx.invoke(reset ? 'resetPairing' : 'pairing');
321
+ if (ctx.signal.aborted)
322
+ return;
323
+ pairingCards = result.cards.filter(item => item.qr.startsWith('data:image/png;base64,') && lan?.urls.some(href => new URL(href).origin === new URL(item.url).origin));
324
+ actionNote = pairingCards.length ? (reset ? (zh ? '旧配对已失效,请重新扫码。' : 'Old pairings revoked. Scan again.') : '')
325
+ : (zh ? '未找到可用配对地址,请检查访问设置。' : 'No pairing address available. Check access settings.');
326
+ drawPairing();
327
+ }
328
+ catch {
329
+ if (!ctx.signal.aborted) {
330
+ actionNote = zh ? '未能取得配对码,请稍后重试。' : 'Could not obtain a pairing code. Please retry.';
331
+ drawPairing();
332
+ }
333
+ }
334
+ finally {
335
+ lanBusy = false;
336
+ resetArmed = false;
337
+ if (!ctx.signal.aborted) {
338
+ resetButton.textContent = zh ? '重置配对' : 'Reset pairing';
339
+ renderLan();
340
+ }
341
+ }
342
+ }
343
+ let pending = false;
344
+ const refresh = async () => {
345
+ if (pending || ctx.signal.aborted)
346
+ return;
347
+ pending = true;
348
+ try {
349
+ const status = await ctx.invoke('status');
350
+ if (ctx.signal.aborted)
351
+ return;
352
+ wake = status.wake ?? null;
353
+ lan = status.lan;
354
+ if (!lanBusy)
355
+ renderLan();
356
+ renderWake();
357
+ let headerFailed = false;
358
+ if (typeof ctx.refresh === 'function') {
359
+ try {
360
+ await ctx.refresh();
361
+ }
362
+ catch {
363
+ headerFailed = true;
364
+ }
365
+ }
366
+ if (ctx.signal.aborted)
367
+ return;
368
+ url = reachableMailbox(status.links ?? (status.url ? [{ href: status.url }] : []), ctx.root.ownerDocument.defaultView?.location?.hostname);
369
+ button.disabled = !url;
370
+ note.textContent = url ? t.ready + (headerFailed ? (zh ? ' 顶栏暂未同步,稍后会重试。' : ' Header sync failed; retrying shortly.') : '') : t.unavailable;
371
+ }
372
+ catch {
373
+ if (!ctx.signal.aborted) {
374
+ wake = null;
375
+ lan = undefined;
376
+ renderLan();
377
+ controls.forEach(item => { item.toggle.disabled = true; item.save.disabled = true; });
378
+ url = null;
379
+ button.disabled = true;
380
+ note.textContent = t.error;
381
+ }
382
+ }
383
+ finally {
384
+ pending = false;
385
+ }
386
+ };
387
+ await refresh();
388
+ if (!ctx.signal.aborted)
389
+ ctx.interval(() => { void refresh(); }, 5000);
390
+ }
391
+ const bundle = { panels: { mailbox: { mount: mountMailbox } } };
392
+ export default bundle;
@@ -0,0 +1,97 @@
1
+ .bottle-mailbox-entry {
2
+ display: grid;
3
+ grid-template-columns: minmax(0, 1fr) auto;
4
+ align-items: center;
5
+ gap: 14px 28px;
6
+ padding: 28px;
7
+ border: 1px solid var(--line-2, #54483d);
8
+ border-radius: 14px;
9
+ background: var(--sheet-2, #25211f);
10
+ color: var(--ink, #f4ede5);
11
+ }
12
+ .bottle-mailbox-entry h2 { margin: 0 0 8px; font-size: 21px; font-weight: 600; }
13
+ .bottle-mailbox-entry p { margin: 0; line-height: 1.65; }
14
+ .bottle-mailbox-entry .bottle-mailbox-copy p,
15
+ .bottle-mailbox-entry .bottle-mailbox-note { color: var(--ink-soft, #d2c5b5); }
16
+ .bottle-mailbox-entry .bottle-open-mailbox {
17
+ min-height: 48px;
18
+ padding: 12px 28px;
19
+ border-radius: 10px;
20
+ background: var(--accent, #a35435);
21
+ color: #fff;
22
+ border: 1px solid var(--accent, #a35435);
23
+ font-size: 16px;
24
+ font-weight: 600;
25
+ white-space: nowrap;
26
+ cursor: pointer;
27
+ }
28
+ .bottle-mailbox-entry .bottle-open-mailbox:hover:not(:disabled) { filter: brightness(1.08); }
29
+ .bottle-mailbox-entry .bottle-open-mailbox:disabled { opacity: .5; cursor: default; }
30
+ .bottle-mailbox-entry .bottle-open-mailbox:focus-visible { outline: 2px solid var(--accent, #a35435); outline-offset: 4px; }
31
+ .bottle-mailbox-entry .bottle-mailbox-note { grid-column: 1 / -1; font-size: 13px; }
32
+ @media (max-width: 600px) {
33
+ .bottle-mailbox-entry { grid-template-columns: minmax(0, 1fr); padding: 22px; gap: 20px; }
34
+ .bottle-mailbox-entry .bottle-open-mailbox { width: 100%; }
35
+ }
36
+
37
+ .bottle-wake-controls { margin-top: 24px; color: var(--ink, #f4ede5); }
38
+ .bottle-wake-controls h3 { margin-bottom: 12px; }
39
+ .bottle-wake-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; }
40
+ .bottle-wake-outcome { color: var(--ink-soft, #d2c5b5); line-height: 1.6; }
41
+
42
+ .bottle-wake-row { flex-wrap: wrap; }
43
+ .bottle-wake-row > span { flex: 1 1 170px; }
44
+ .bottle-wake-interval { display: flex; align-items: center; gap: 8px; font-size: 12px; }
45
+ .bottle-wake-interval input { width: 62px; padding: 7px; border: 1px solid var(--line, #63564b); border-radius: 6px; background: transparent; color: inherit; }
46
+
47
+
48
+ /* A single pairing station: form on the left, one selected QR on the right. */
49
+ .bottle-lan-card { container-type: inline-size; margin-top: 28px; border: 1px solid var(--line-2, #54483d); border-radius: 14px; background: var(--sheet-2, #25211f); color: var(--ink, #f4ede5); overflow: hidden; }
50
+ .bottle-lan-card *, .bottle-lan-card *::before, .bottle-lan-card *::after { box-sizing: border-box; }
51
+ .bottle-lan-card h3, .bottle-lan-card h4, .bottle-lan-card p, .bottle-lan-card figure { margin: 0; color: inherit; }
52
+ .bottle-lan-card h3 { font-size: 18px; font-weight: 600; line-height: 1.5; }
53
+ .bottle-lan-card h4 { font-size: 14px; font-weight: 600; line-height: 1.5; margin-bottom: 20px; }
54
+ .bottle-lan-card p { font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
55
+ .bottle-lan-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 24px; border-bottom: 1px solid var(--line-2, #54483d); }
56
+ .bottle-lan-header p { margin-top: 6px; color: var(--ink-soft, #bbc4ce); }
57
+ .bottle-lan-badge { flex-shrink: 0; font-size: 12px; line-height: 1.5; border: 1px solid var(--line-2, #54483d); padding: 4px 10px; border-radius: 20px; color: var(--ink-soft, #bbc4ce); }
58
+ .bottle-lan-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, .9fr); gap: 32px; padding: 24px; align-items: start; }
59
+ .bottle-lan-settings, .bottle-lan-pairing { min-width: 0; }
60
+ .bottle-lan-pairing { padding-left: 28px; border-left: 1px solid var(--line-2, #54483d); }
61
+ .bottle-lan-toggle { display: flex; align-items: center; gap: 10px; min-height: 40px; margin-bottom: 20px; font-size: 14px; cursor: pointer; }
62
+ .bottle-lan-toggle input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent, #557fbb); }
63
+ .bottle-lan-field { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: 0 0 16px; font-size: 13px; line-height: 1.6; }
64
+ .bottle-lan-card .bottle-lan-field input, .bottle-lan-card select, .bottle-lan-link input { width: 100%; min-width: 0; height: 40px; padding: 8px 12px; font: inherit; color: var(--ink, #f4ede5); background: var(--sheet-2, #25211f); border: 1px solid var(--line-2, #65584b); border-radius: 8px; }
65
+ .bottle-lan-card input::placeholder { color: var(--ink-soft, #bbc4ce); opacity: .65; }
66
+ .bottle-lan-card select { overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
67
+ .bottle-lan-card .bottle-lan-help { color: var(--ink-soft, #bbc4ce); font-size: 12px; }
68
+ .bottle-lan-card .bottle-lan-save { margin: 20px 0 10px; }
69
+ .bottle-lan-qr-list { min-height: 260px; display: grid; align-items: center; justify-items: center; }
70
+ .bottle-lan-card .bottle-lan-qr { width: 100%; min-width: 0; display: grid; justify-items: center; gap: 12px; animation: bottle-pair-reveal .2s ease-out; }
71
+ .bottle-lan-qr img { display: block; width: 224px; max-width: 100%; height: auto; background: white; border-radius: 10px; }
72
+ .bottle-lan-qr figcaption { text-align: center; color: var(--ink-soft, #bbc4ce); font-size: 12px; line-height: 1.6; }
73
+ .bottle-lan-link { width: 100%; min-width: 0; color: var(--ink-soft, #bbc4ce); font-size: 12px; }
74
+ .bottle-lan-link summary { width: fit-content; margin: 0 auto; cursor: pointer; padding: 4px; }
75
+ .bottle-lan-link input { margin-top: 10px; }
76
+ .bottle-lan-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 250px; padding: 20px; text-align: center; border: 1px dashed var(--line-2, #54483d); border-radius: 10px; }
77
+ .bottle-lan-empty span { font-size: 14px; }
78
+ .bottle-lan-empty p { color: var(--ink-soft, #bbc4ce); font-size: 12px; }
79
+ .bottle-lan-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
80
+ .bottle-lan-card .bottle-lan-feedback { min-height: 20px; margin-top: 12px; color: var(--ink-soft, #bbc4ce); text-align: center; font-size: 12px; }
81
+ .bottle-lan-footer { padding: 18px 24px; border-top: 1px solid var(--line-2, #54483d); }
82
+ .bottle-lan-card .bottle-lan-warning { color: color-mix(in srgb, #e5484d 75%, var(--ink, #f4ede5)); font-size: 12px; }
83
+ .bottle-lan-footer .bottle-lan-help { margin-top: 8px; }
84
+ .bottle-lan-card button { min-height: 40px; padding: 9px 16px; font: inherit; font-size: 13px; line-height: 1.4; border: 1px solid var(--line-2, #65584b); border-radius: 8px; background: transparent; color: var(--ink, #f4ede5); cursor: pointer; }
85
+ .bottle-lan-card .bottle-lan-reveal { background: var(--accent, #557fbb); border-color: var(--accent, #557fbb); color: #fff; }
86
+ .bottle-lan-card button:hover:not(:disabled) { filter: brightness(1.12); border-color: var(--accent, #557fbb); }
87
+ .bottle-lan-card button:disabled { opacity: .5; cursor: default; }
88
+ .bottle-lan-card button:focus-visible, .bottle-lan-card input:focus-visible, .bottle-lan-card select:focus-visible, .bottle-lan-link summary:focus-visible { outline: 2px solid var(--accent, #557fbb); outline-offset: 3px; }
89
+ .bottle-lan-card button, .bottle-lan-card input, .bottle-lan-card select { transition: background-color .18s, color .18s, border-color .18s, opacity .18s; }
90
+ @keyframes bottle-pair-reveal { from { opacity: 0; } to { opacity: 1; } }
91
+ @container (max-width: 640px) {
92
+ .bottle-lan-body { grid-template-columns: minmax(0, 1fr); gap: 24px; }
93
+ .bottle-lan-pairing { padding: 24px 0 0; border-left: 0; border-top: 1px solid var(--line-2, #54483d); }
94
+ .bottle-lan-header, .bottle-lan-body { padding: 20px; }
95
+ .bottle-lan-footer { padding: 16px 20px; }
96
+ }
97
+ @media (prefers-reduced-motion: reduce) { .bottle-lan-card *, .bottle-lan-qr { animation: none; transition: none; } }
package/dist/webui.css CHANGED
@@ -43,3 +43,55 @@
43
43
  .bottle-wake-row > span { flex: 1 1 170px; }
44
44
  .bottle-wake-interval { display: flex; align-items: center; gap: 8px; font-size: 12px; }
45
45
  .bottle-wake-interval input { width: 62px; padding: 7px; border: 1px solid var(--line, #63564b); border-radius: 6px; background: transparent; color: inherit; }
46
+
47
+
48
+ /* A single pairing station: form on the left, one selected QR on the right. */
49
+ .bottle-lan-card { container-type: inline-size; margin-top: 28px; border: 1px solid var(--line-2, #54483d); border-radius: 14px; background: var(--sheet-2, #25211f); color: var(--ink, #f4ede5); overflow: hidden; }
50
+ .bottle-lan-card *, .bottle-lan-card *::before, .bottle-lan-card *::after { box-sizing: border-box; }
51
+ .bottle-lan-card h3, .bottle-lan-card h4, .bottle-lan-card p, .bottle-lan-card figure { margin: 0; color: inherit; }
52
+ .bottle-lan-card h3 { font-size: 18px; font-weight: 600; line-height: 1.5; }
53
+ .bottle-lan-card h4 { font-size: 14px; font-weight: 600; line-height: 1.5; margin-bottom: 20px; }
54
+ .bottle-lan-card p { font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
55
+ .bottle-lan-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 24px; border-bottom: 1px solid var(--line-2, #54483d); }
56
+ .bottle-lan-header p { margin-top: 6px; color: var(--ink-soft, #bbc4ce); }
57
+ .bottle-lan-badge { flex-shrink: 0; font-size: 12px; line-height: 1.5; border: 1px solid var(--line-2, #54483d); padding: 4px 10px; border-radius: 20px; color: var(--ink-soft, #bbc4ce); }
58
+ .bottle-lan-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, .9fr); gap: 32px; padding: 24px; align-items: start; }
59
+ .bottle-lan-settings, .bottle-lan-pairing { min-width: 0; }
60
+ .bottle-lan-pairing { padding-left: 28px; border-left: 1px solid var(--line-2, #54483d); }
61
+ .bottle-lan-toggle { display: flex; align-items: center; gap: 10px; min-height: 40px; margin-bottom: 20px; font-size: 14px; cursor: pointer; }
62
+ .bottle-lan-toggle input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent, #557fbb); }
63
+ .bottle-lan-field { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: 0 0 16px; font-size: 13px; line-height: 1.6; }
64
+ .bottle-lan-card .bottle-lan-field input, .bottle-lan-card select, .bottle-lan-link input { width: 100%; min-width: 0; height: 40px; padding: 8px 12px; font: inherit; color: var(--ink, #f4ede5); background: var(--sheet-2, #25211f); border: 1px solid var(--line-2, #65584b); border-radius: 8px; }
65
+ .bottle-lan-card input::placeholder { color: var(--ink-soft, #bbc4ce); opacity: .65; }
66
+ .bottle-lan-card select { overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
67
+ .bottle-lan-card .bottle-lan-help { color: var(--ink-soft, #bbc4ce); font-size: 12px; }
68
+ .bottle-lan-card .bottle-lan-save { margin: 20px 0 10px; }
69
+ .bottle-lan-qr-list { min-height: 260px; display: grid; align-items: center; justify-items: center; }
70
+ .bottle-lan-card .bottle-lan-qr { width: 100%; min-width: 0; display: grid; justify-items: center; gap: 12px; animation: bottle-pair-reveal .2s ease-out; }
71
+ .bottle-lan-qr img { display: block; width: 224px; max-width: 100%; height: auto; background: white; border-radius: 10px; }
72
+ .bottle-lan-qr figcaption { text-align: center; color: var(--ink-soft, #bbc4ce); font-size: 12px; line-height: 1.6; }
73
+ .bottle-lan-link { width: 100%; min-width: 0; color: var(--ink-soft, #bbc4ce); font-size: 12px; }
74
+ .bottle-lan-link summary { width: fit-content; margin: 0 auto; cursor: pointer; padding: 4px; }
75
+ .bottle-lan-link input { margin-top: 10px; }
76
+ .bottle-lan-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 250px; padding: 20px; text-align: center; border: 1px dashed var(--line-2, #54483d); border-radius: 10px; }
77
+ .bottle-lan-empty span { font-size: 14px; }
78
+ .bottle-lan-empty p { color: var(--ink-soft, #bbc4ce); font-size: 12px; }
79
+ .bottle-lan-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
80
+ .bottle-lan-card .bottle-lan-feedback { min-height: 20px; margin-top: 12px; color: var(--ink-soft, #bbc4ce); text-align: center; font-size: 12px; }
81
+ .bottle-lan-footer { padding: 18px 24px; border-top: 1px solid var(--line-2, #54483d); }
82
+ .bottle-lan-card .bottle-lan-warning { color: color-mix(in srgb, #e5484d 75%, var(--ink, #f4ede5)); font-size: 12px; }
83
+ .bottle-lan-footer .bottle-lan-help { margin-top: 8px; }
84
+ .bottle-lan-card button { min-height: 40px; padding: 9px 16px; font: inherit; font-size: 13px; line-height: 1.4; border: 1px solid var(--line-2, #65584b); border-radius: 8px; background: transparent; color: var(--ink, #f4ede5); cursor: pointer; }
85
+ .bottle-lan-card .bottle-lan-reveal { background: var(--accent, #557fbb); border-color: var(--accent, #557fbb); color: #fff; }
86
+ .bottle-lan-card button:hover:not(:disabled) { filter: brightness(1.12); border-color: var(--accent, #557fbb); }
87
+ .bottle-lan-card button:disabled { opacity: .5; cursor: default; }
88
+ .bottle-lan-card button:focus-visible, .bottle-lan-card input:focus-visible, .bottle-lan-card select:focus-visible, .bottle-lan-link summary:focus-visible { outline: 2px solid var(--accent, #557fbb); outline-offset: 3px; }
89
+ .bottle-lan-card button, .bottle-lan-card input, .bottle-lan-card select { transition: background-color .18s, color .18s, border-color .18s, opacity .18s; }
90
+ @keyframes bottle-pair-reveal { from { opacity: 0; } to { opacity: 1; } }
91
+ @container (max-width: 640px) {
92
+ .bottle-lan-body { grid-template-columns: minmax(0, 1fr); gap: 24px; }
93
+ .bottle-lan-pairing { padding: 24px 0 0; border-left: 0; border-top: 1px solid var(--line-2, #54483d); }
94
+ .bottle-lan-header, .bottle-lan-body { padding: 20px; }
95
+ .bottle-lan-footer { padding: 16px 20px; }
96
+ }
97
+ @media (prefers-reduced-motion: reduce) { .bottle-lan-card *, .bottle-lan-qr { animation: none; transition: none; } }