@akira-yylm/session-calendar 1.1.2 → 2.0.2

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.
package/client.js CHANGED
@@ -47,6 +47,63 @@ window.__ModuleLoader__.load({
47
47
  */
48
48
  const PALETTE = ['#FC757B', '#F97F5F', '#FAA26F', '#FDCD94', '#FEE199', '#B0D6A9', '#65BDBA', '#3C9BC9']
49
49
 
50
+ /** The background the card ships with: the host's own menu surface. */
51
+ const DEFAULT_BACKGROUND = { mode: 'default', color: '#303136', alpha: 94, image: '', imageAlpha: 60, imageX: 50, imageY: 50, imageZoom: 100 }
52
+
53
+ /**
54
+ * Read the theme's resolved menu colour so "colour" mode starts from the
55
+ * look the reader already has instead of a black swatch. Accepts the
56
+ * `rgb()/rgba()` form a computed style returns.
57
+ */
58
+ function parseCssColor(raw) {
59
+ const text = String(raw).trim()
60
+ const match = /^rgba?\(([^)]+)\)$/i.exec(text)
61
+ if (match === null) return null
62
+ const parts = match[1].split(/[\s,/]+/).filter((part) => part !== '').map(Number)
63
+ if (parts.length < 3 || parts.slice(0, 3).some((value) => !Number.isFinite(value))) return null
64
+ return {
65
+ color: toHex(parts.slice(0, 3)),
66
+ alpha: parts.length > 3 && Number.isFinite(parts[3]) ? Math.round(parts[3] * 100) : 100,
67
+ }
68
+ }
69
+
70
+ /** An independent copy of a look, so a saved profile never aliases the draft. */
71
+ function cloneLook(look) {
72
+ return {
73
+ ...look,
74
+ background: { ...look.background },
75
+ palette: look.palette.slice(),
76
+ fontRecent: look.fontRecent.slice(0, 3),
77
+ }
78
+ }
79
+
80
+ /** The brand blue the controls select with; customisable like the rest. */
81
+ const DEFAULT_ACCENT = '#4D6BFE'
82
+
83
+ /**
84
+ * One complete look: a background, the interface colour family, the selected
85
+ * colour, and optional overrides for borders, text and the font. An empty
86
+ * string means "keep the host's own value".
87
+ */
88
+ function defaultSettings() {
89
+ return {
90
+ background: { ...DEFAULT_BACKGROUND },
91
+ palette: PALETTE.slice(),
92
+ accent: DEFAULT_ACCENT,
93
+ border: '',
94
+ text: '',
95
+ font: '',
96
+ fontWeight: '',
97
+ // The last three chosen families, shown above the separator.
98
+ fontRecent: [],
99
+ // The sidebar row can deviate from the rest.
100
+ launchIcon: '',
101
+ launchText: '',
102
+ launchBorder: '',
103
+ launchBg: '',
104
+ }
105
+ }
106
+
50
107
  // ---------------------------------------------------------------------
51
108
  // Workspace colours.
52
109
  //
@@ -88,15 +145,15 @@ window.__ModuleLoader__.load({
88
145
  * through {@link PALETTE}, so `size === PALETTE.length` returns the eight
89
146
  * chosen colours unchanged and any other size is the same family resampled.
90
147
  */
91
- function familyStops(size) {
92
- const last = PALETTE.length - 1
148
+ function familyStops(size, palette = PALETTE) {
149
+ const last = palette.length - 1
93
150
  const stops = []
94
151
  for (let index = 0; index < size; index += 1) {
95
152
  const position = size <= 1 ? 0 : (index / (size - 1)) * last
96
153
  const lower = Math.min(Math.floor(position), last - 1)
97
154
  const fraction = position - lower
98
- const from = toRgb(PALETTE[lower])
99
- const to = toRgb(PALETTE[lower + 1])
155
+ const from = toRgb(palette[lower])
156
+ const to = toRgb(palette[lower + 1])
100
157
  stops.push(toHex([
101
158
  from[0] + (to[0] - from[0]) * fraction,
102
159
  from[1] + (to[1] - from[1]) * fraction,
@@ -107,17 +164,17 @@ window.__ModuleLoader__.load({
107
164
  }
108
165
 
109
166
  /** The colours for `count` Workspaces, in Workspace order. */
110
- function workspacePalette(count) {
167
+ function workspacePalette(count, palette = PALETTE) {
111
168
  if (count <= 0) return []
112
- if (count <= PALETTE.length && PALETTE.length % count === 0) {
113
- const step = PALETTE.length / count
169
+ if (count <= palette.length && palette.length % count === 0) {
170
+ const step = palette.length / count
114
171
  const picked = []
115
- for (let index = 0; index < count; index += 1) picked.push(PALETTE[index * step])
172
+ for (let index = 0; index < count; index += 1) picked.push(palette[index * step])
116
173
  return picked
117
174
  }
118
- let size = PALETTE.length
175
+ let size = palette.length
119
176
  while (size % count !== 0) size += 1
120
- const stops = familyStops(size)
177
+ const stops = familyStops(size, palette)
121
178
  const picked = []
122
179
  for (let index = 0; index < count; index += 1) {
123
180
  const position = count === 1 ? 0 : (index * (size - 1)) / (count - 1)
@@ -128,9 +185,10 @@ window.__ModuleLoader__.load({
128
185
 
129
186
  /** Memoised `workspacePalette`, because it runs on every render. */
130
187
  const paletteCache = new Map()
131
- function paletteFor(count) {
132
- if (!paletteCache.has(count)) paletteCache.set(count, workspacePalette(count))
133
- return paletteCache.get(count)
188
+ function paletteFor(count, palette = PALETTE) {
189
+ const key = count + '|' + palette.join(',')
190
+ if (!paletteCache.has(key)) paletteCache.set(key, workspacePalette(count, palette))
191
+ return paletteCache.get(key)
134
192
  }
135
193
 
136
194
  /**
@@ -191,6 +249,51 @@ window.__ModuleLoader__.load({
191
249
  'mode.last': '最近',
192
250
  'mode.switch': '按第一次对话时间 / 按最近一次对话时间',
193
251
  close: '关闭会话日历',
252
+ settings: '外观设置',
253
+ theme: '主题色',
254
+ accentColor: '选中色',
255
+ borderColor: '边框颜色',
256
+ textColor: '文字颜色',
257
+ fontFamily: '字体',
258
+ fontDefault: '默认字体',
259
+ searchFont: '搜索字体…',
260
+ noFontMatch: '没有匹配的字体',
261
+ pluginButton: '插件按钮',
262
+ resetValue: '点击恢复默认',
263
+ launchIcon: '入口图标',
264
+ launchText: '插件字体',
265
+ launchBorder: '入口边框',
266
+ launchBg: '入口背景',
267
+ auto: '自动',
268
+ defaultAccent: '默认',
269
+ background: '背景',
270
+ bgDefault: '默认',
271
+ bgColor: '纯色',
272
+ bgImage: '照片',
273
+ color: '颜色',
274
+ opacity: '透明度',
275
+ zoom: '缩放',
276
+ pickImage: '选择本地照片',
277
+ replaceImage: '更换照片',
278
+ removeImage: '移除照片',
279
+ photoPosition: '拖动调整照片位置',
280
+ resetPosition: '恢复默认位置',
281
+ photoPositionHint: '拖动调整位置;滚轮缩放;方向键微调',
282
+ palette: '主界面色系',
283
+ resetPalette: '默认',
284
+ addColor: '添加一个颜色',
285
+ moveLeft: '左移一位',
286
+ moveRight: '右移一位',
287
+ removeColor: '删除选中的颜色',
288
+ profiles: '配置文件',
289
+ saveProfile: '保存到当前配置',
290
+ saveAsProfile: '另存为',
291
+ renameProfile: '重命名',
292
+ pin: '固定:重新打开日历时保留设置面板',
293
+ unpin: '取消固定:重新打开日历时不显示设置面板',
294
+ deleteProfile: '删除配置',
295
+ profileName: '新配置名称',
296
+ untitledProfile: '未命名配置',
194
297
  today: '今天',
195
298
  prevMonth: '上个月',
196
299
  nextMonth: '下个月',
@@ -238,6 +341,51 @@ window.__ModuleLoader__.load({
238
341
  'mode.last': 'Latest',
239
342
  'mode.switch': 'Group by first prompt or by latest conversation',
240
343
  close: 'Close the session calendar',
344
+ settings: 'Appearance',
345
+ theme: 'Theme colours',
346
+ accentColor: 'Selected',
347
+ borderColor: 'Borders',
348
+ textColor: 'Text',
349
+ fontFamily: 'Font',
350
+ fontDefault: 'Default font',
351
+ searchFont: 'Search fonts…',
352
+ noFontMatch: 'No matching font',
353
+ pluginButton: 'Plugin button',
354
+ resetValue: 'Click to reset',
355
+ launchIcon: 'Button icon',
356
+ launchText: 'Button text',
357
+ launchBorder: 'Button border',
358
+ launchBg: 'Button background',
359
+ auto: 'Auto',
360
+ defaultAccent: 'Default',
361
+ background: 'Background',
362
+ bgDefault: 'Default',
363
+ bgColor: 'Colour',
364
+ bgImage: 'Photo',
365
+ color: 'Colour',
366
+ opacity: 'Opacity',
367
+ zoom: 'Zoom',
368
+ pickImage: 'Choose a local photo',
369
+ replaceImage: 'Replace the photo',
370
+ removeImage: 'Remove the photo',
371
+ photoPosition: 'Drag to position the photo',
372
+ resetPosition: 'Reset position',
373
+ photoPositionHint: 'Drag to position; wheel to zoom; arrow keys to nudge',
374
+ palette: 'Interface colours',
375
+ resetPalette: 'Default',
376
+ addColor: 'Add a colour',
377
+ moveLeft: 'Move left',
378
+ moveRight: 'Move right',
379
+ removeColor: 'Remove the picked colour',
380
+ profiles: 'Profile files',
381
+ saveProfile: 'Save to this profile',
382
+ saveAsProfile: 'Save as',
383
+ renameProfile: 'Rename',
384
+ pin: 'Keep the editor open when the calendar reopens',
385
+ unpin: 'Do not keep the editor open when the calendar reopens',
386
+ deleteProfile: 'Delete profile',
387
+ profileName: 'New profile name',
388
+ untitledProfile: 'Untitled profile',
241
389
  today: 'Today',
242
390
  prevMonth: 'Previous month',
243
391
  nextMonth: 'Next month',
@@ -303,10 +451,222 @@ window.__ModuleLoader__.load({
303
451
  */
304
452
  let lastMode = 'first'
305
453
 
454
+ /** Pinned editor: it reopens with the calendar and survives a close. */
455
+ let settingsPinned = false
456
+
306
457
  /** Workspace groups the reader folded shut, by group key. */
307
458
  const collapsedGroups = new Set()
308
459
 
309
460
 
461
+ // ---------------------------------------------------------------------
462
+ // Custom looks.
463
+ //
464
+ // Two things are adjustable: the card's own background (a colour with an
465
+ // opacity, or a local photo with an opacity) and the colour family every
466
+ // Workspace colour derives from. Both ship with the values above as the
467
+ // default, and a reader can keep several named profiles.
468
+ // ---------------------------------------------------------------------
469
+
470
+ const SETTINGS_KEY = 'dsh-session-calendar/settings/v1'
471
+ /**
472
+ * The durable copy. Desktop serves the Web application from an ephemeral
473
+ * port, so `localStorage` (per origin) cannot outlive a restart; the Host
474
+ * half writes this same payload to a file instead.
475
+ */
476
+ const SETTINGS_ROUTE = '/dsh-session-calendar/settings.json'
477
+
478
+ /** `{ active, draft, profiles }`; the draft is what the UI shows. */
479
+ let settingsState = { active: '默认', draft: defaultSettings(), profiles: {} }
480
+ const settingsListeners = new Set()
481
+ let settingsLoaded = false
482
+
483
+ /** Clamp a stored look into the shape the UI expects. */
484
+ function normaliseSettings(raw) {
485
+ const fallback = defaultSettings()
486
+ if (raw === null || typeof raw !== 'object') return fallback
487
+ const background = raw.background !== null && typeof raw.background === 'object' ? raw.background : {}
488
+ const mode = background.mode === 'color' || background.mode === 'image' ? background.mode : 'default'
489
+ const palette = Array.isArray(raw.palette)
490
+ ? raw.palette.map((value) => String(value)).filter((value) => /^#[0-9a-fA-F]{6}$/.test(value)).slice(0, 12)
491
+ : []
492
+ const colour = (value, fallbackValue) => (/^#[0-9a-fA-F]{6}$/.test(String(value)) ? String(value).toUpperCase() : fallbackValue)
493
+ return {
494
+ background: {
495
+ mode,
496
+ color: colour(background.color, fallback.background.color),
497
+ alpha: Number.isFinite(background.alpha) ? Math.max(0, Math.min(100, Math.round(background.alpha))) : fallback.background.alpha,
498
+ image: typeof background.image === 'string' ? background.image : '',
499
+ imageAlpha: Number.isFinite(background.imageAlpha)
500
+ ? Math.max(0, Math.min(100, Math.round(background.imageAlpha)))
501
+ : fallback.background.imageAlpha,
502
+ imageX: Number.isFinite(background.imageX) ? Math.max(0, Math.min(100, Math.round(background.imageX))) : fallback.background.imageX,
503
+ imageY: Number.isFinite(background.imageY) ? Math.max(0, Math.min(100, Math.round(background.imageY))) : fallback.background.imageY,
504
+ imageZoom: Number.isFinite(background.imageZoom)
505
+ ? Math.max(100, Math.min(300, Math.round(background.imageZoom)))
506
+ : fallback.background.imageZoom,
507
+ },
508
+ palette: palette.length >= 2 ? palette : fallback.palette,
509
+ accent: colour(raw.accent, DEFAULT_ACCENT),
510
+ border: colour(raw.border, ''),
511
+ text: colour(raw.text, ''),
512
+ font: typeof raw.font === 'string' ? raw.font.slice(0, 120) : '',
513
+ fontWeight: ['300', '400', '500', '600', '700'].includes(String(raw.fontWeight)) ? String(raw.fontWeight) : '',
514
+ fontRecent: Array.isArray(raw.fontRecent)
515
+ ? raw.fontRecent.filter((value) => typeof value === 'string' && value !== '').slice(0, 3)
516
+ : [],
517
+ launchIcon: colour(raw.launchIcon, ''),
518
+ launchText: colour(raw.launchText, ''),
519
+ launchBorder: colour(raw.launchBorder, ''),
520
+ launchBg: colour(raw.launchBg, ''),
521
+ }
522
+ }
523
+
524
+ /** Turn a stored payload (from the cache or the host file) into settings. */
525
+ function parseStored(parsed) {
526
+ const profiles = {}
527
+ if (parsed !== null && typeof parsed === 'object' && parsed.profiles !== null && typeof parsed.profiles === 'object') {
528
+ for (const [name, value] of Object.entries(parsed.profiles)) {
529
+ if (typeof name === 'string' && name !== '') profiles[name] = normaliseSettings(value)
530
+ }
531
+ }
532
+ return {
533
+ active: typeof parsed?.active === 'string' && parsed.active !== '' ? parsed.active : '默认',
534
+ draft: normaliseSettings(parsed?.draft),
535
+ profiles,
536
+ }
537
+ }
538
+
539
+ function readSettings() {
540
+ if (settingsLoaded) return
541
+ settingsLoaded = true
542
+ try {
543
+ const raw = window.localStorage.getItem(SETTINGS_KEY)
544
+ if (raw === null) return
545
+ settingsState = parseStored(JSON.parse(raw))
546
+ } catch {
547
+ // Unreadable storage keeps the defaults; nothing else to do.
548
+ }
549
+ }
550
+
551
+ let persistTimer = null
552
+
553
+ /** Write the look back, coalesced: dragging a colour fires many changes. */
554
+ /** Copy the current settings to the Host file; failures only cost durability. */
555
+ function pushSettingsToHost() {
556
+ try {
557
+ const body = JSON.stringify(settingsState)
558
+ void fetch(SETTINGS_ROUTE, {
559
+ method: 'PUT',
560
+ credentials: 'same-origin',
561
+ headers: { 'content-type': 'application/json' },
562
+ body,
563
+ }).catch(() => undefined)
564
+ } catch {
565
+ // No fetch (an unusual embed) — the cache still works.
566
+ }
567
+ }
568
+
569
+ function persistSettings() {
570
+ if (persistTimer !== null) return
571
+ persistTimer = window.setTimeout(() => {
572
+ persistTimer = null
573
+ const body = JSON.stringify(settingsState)
574
+ try {
575
+ window.localStorage.setItem(SETTINGS_KEY, body)
576
+ } catch {
577
+ // A full or blocked store only costs the cheap cache.
578
+ }
579
+ pushSettingsToHost()
580
+ }, 250)
581
+ }
582
+
583
+ /**
584
+ * Load the durable copy once at startup, and migrate an older local copy up
585
+ * when the file does not exist yet. The local read has already happened, so
586
+ * the UI can paint before this resolves.
587
+ */
588
+ let hostSettingsRead = false
589
+ async function syncSettingsWithHost() {
590
+ if (hostSettingsRead) return
591
+ hostSettingsRead = true
592
+ try {
593
+ const response = await fetch(SETTINGS_ROUTE, { cache: 'no-store', credentials: 'same-origin' })
594
+ if (!response.ok) return
595
+ const payload = await response.json()
596
+ const stored = payload !== null && typeof payload === 'object' ? payload.settings : null
597
+ if (stored !== null && typeof stored === 'object') {
598
+ settingsState = parseStored(stored)
599
+ publishSettings(settingsState)
600
+ return
601
+ }
602
+ // First run with this version: keep what this origin already has.
603
+ let local = null
604
+ try {
605
+ const raw = window.localStorage.getItem(SETTINGS_KEY)
606
+ if (raw !== null) local = JSON.parse(raw)
607
+ } catch {
608
+ local = null
609
+ }
610
+ if (local !== null && typeof local === 'object') {
611
+ settingsState = parseStored(local)
612
+ publishSettings(settingsState)
613
+ pushSettingsToHost()
614
+ }
615
+ } catch {
616
+ // An older Host without the route: stay on the browser copy.
617
+ }
618
+ }
619
+
620
+ function publishSettings(next) {
621
+ settingsState = next
622
+ persistSettings()
623
+ for (const listener of settingsListeners) listener()
624
+ }
625
+
626
+ function subscribeSettings(listener) {
627
+ readSettings()
628
+ settingsListeners.add(listener)
629
+ return () => { settingsListeners.delete(listener) }
630
+ }
631
+
632
+ /** The look currently in effect (the draft; unedited it is the default). */
633
+ function useSettings() {
634
+ return React.useSyncExternalStore(subscribeSettings, () => settingsState)
635
+ }
636
+
637
+ /**
638
+ * The look as inline custom properties. Empty overrides are simply absent,
639
+ * so the stylesheet's theme tokens take over.
640
+ */
641
+ function lookStyle(look) {
642
+ const style = {}
643
+ if (look.accent !== '' && look.accent !== undefined) style['--sc-calendar-accent'] = look.accent
644
+ if (look.border !== '' && look.border !== undefined) style['--sc-border'] = look.border
645
+ if (look.text !== '' && look.text !== undefined) {
646
+ style['--sc-text-strong'] = look.text
647
+ style['--sc-text'] = 'color-mix(in srgb, ' + look.text + ' 78%, transparent)'
648
+ style['--sc-text-dim'] = 'color-mix(in srgb, ' + look.text + ' 55%, transparent)'
649
+ }
650
+ if (look.font !== '' && look.font !== undefined) {
651
+ style.fontFamily = cssFamily(look.font)
652
+ // A plain regular pick leaves the host's own weights untouched.
653
+ if (look.fontWeight !== '' && look.fontWeight !== undefined && look.fontWeight !== '400') {
654
+ style.fontWeight = look.fontWeight
655
+ }
656
+ }
657
+ if (look.launchIcon !== '' && look.launchIcon !== undefined) style['--sc-launch-icon'] = look.launchIcon
658
+ if (look.launchText !== '' && look.launchText !== undefined) style['--sc-launch-text'] = look.launchText
659
+ if (look.launchBorder !== '' && look.launchBorder !== undefined) style['--sc-launch-border'] = look.launchBorder
660
+ if (look.launchBg !== '' && look.launchBg !== undefined) style['--sc-launch-bg'] = look.launchBg
661
+ return style
662
+ }
663
+
664
+ function updateSettings(mutate) {
665
+ readSettings()
666
+ const next = mutate({ ...settingsState, draft: { ...settingsState.draft } })
667
+ publishSettings(next)
668
+ }
669
+
310
670
  let shared = { open: false, anchor: null, trigger: null }
311
671
  const listeners = new Set()
312
672
 
@@ -319,6 +679,51 @@ window.__ModuleLoader__.load({
319
679
  for (const listener of listeners) listener()
320
680
  }
321
681
 
682
+ /**
683
+ * The sidebar's outer right edge, which the calendar should hug.
684
+ *
685
+ * The entry is width:100% of its row, but rows sit inside the column's
686
+ * padding, so the button's own right edge is not the column's. The column is
687
+ * the ancestor that runs the full height of the frame (rows are ~30px tall),
688
+ * while the things above it span the whole window. Pick the tallest narrow
689
+ * one and take its right edge; fall back to the widest narrow one.
690
+ */
691
+ function sidebarEdgeRight(element) {
692
+ if (element === null || element === undefined) return 268
693
+ // Prefer the sidebar landmark itself when the host marks it up: that edge
694
+ // is exact, no heuristics involved.
695
+ if (typeof element.closest === 'function') {
696
+ const column = element.closest('nav, aside, [role="navigation"], [role="complementary"]')
697
+ if (column !== null && column !== undefined) {
698
+ return column.getBoundingClientRect().right
699
+ }
700
+ }
701
+ const viewportWidth = typeof window === 'undefined' ? 1440 : window.innerWidth
702
+ const viewportHeight = typeof window === 'undefined' ? 900 : window.innerHeight
703
+ const narrowLimit = viewportWidth * 0.6
704
+ let tall = null
705
+ let tallHeight = 0
706
+ let widest = null
707
+ let widestWidth = 0
708
+ let node = element.parentElement
709
+ while (node !== null && node !== undefined && node !== document.body) {
710
+ const rect = node.getBoundingClientRect()
711
+ if (rect.width > narrowLimit) break
712
+ if (rect.width > widestWidth) {
713
+ widestWidth = rect.width
714
+ widest = rect.right
715
+ }
716
+ if (rect.height >= viewportHeight * 0.5 && rect.width > 120 && rect.height > tallHeight) {
717
+ tallHeight = rect.height
718
+ tall = rect.right
719
+ }
720
+ node = node.parentElement
721
+ }
722
+ if (tall !== null) return tall
723
+ if (widest !== null) return widest
724
+ return element.getBoundingClientRect().right
725
+ }
726
+
322
727
  function openWith(anchor, trigger) {
323
728
  publish({ open: true, anchor, trigger })
324
729
  }
@@ -410,6 +815,305 @@ window.__ModuleLoader__.load({
410
815
  )
411
816
  }
412
817
 
818
+ /** A cog: the settings entry beside the month. */
819
+ function GearGlyph({ size = 14 }) {
820
+ return h(
821
+ 'svg',
822
+ glyphProps(size),
823
+ h('circle', {
824
+ cx: 12, cy: 12, r: 3.4,
825
+ fill: 'none', stroke: 'currentColor', strokeWidth: 1.6,
826
+ }),
827
+ h('circle', {
828
+ cx: 12, cy: 12, r: 7.8,
829
+ fill: 'none', stroke: 'currentColor', strokeWidth: 2.1, strokeDasharray: '2.2 2.5',
830
+ }),
831
+ )
832
+ }
833
+
834
+ /** A thumbtack: keeps the look editor open across reopenings. */
835
+ function PinGlyph({ size = 14 }) {
836
+ return h(
837
+ 'svg',
838
+ glyphProps(size),
839
+ h('path', {
840
+ d: 'M9.2 3.6h5.6l-.8 5 3 2.7v1.5h-4.2V20l-.8 1-.8-1v-7.2H7v-1.5l3-2.7-.8-5Z',
841
+ fill: 'none',
842
+ stroke: 'currentColor',
843
+ strokeWidth: 1.5,
844
+ strokeLinejoin: 'round',
845
+ }),
846
+ )
847
+ }
848
+
849
+ /** Common macOS families, used until the browser hands over the real list. */
850
+ const FALLBACK_FONTS = [
851
+ 'PingFang SC', 'PingFang HK', 'PingFang TC', 'Hiragino Sans GB', 'Hiragino Sans',
852
+ 'Heiti SC', 'Songti SC', 'Kaiti SC', 'STSong', 'STKaiti', 'STHeiti', 'STFangsong',
853
+ 'Yuanti SC', 'Libian SC', 'Weibei SC', 'Xingkai SC', 'Hannotate SC', 'HanziPen SC',
854
+ 'Wawati SC', 'Baoli SC', 'Lantinghei SC', 'Fangsong', 'Noto Sans SC', 'Noto Serif SC',
855
+ 'Source Han Sans SC', 'Source Han Serif SC', 'Helvetica Neue', 'Helvetica', 'Arial',
856
+ 'Arial Narrow', 'Times New Roman', 'Times', 'Georgia', 'Palatino', 'Baskerville',
857
+ 'Didot', 'Optima', 'Futura', 'Gill Sans', 'Trebuchet MS', 'Verdana', 'Tahoma',
858
+ 'Courier New', 'Courier', 'Menlo', 'Monaco', 'SF Mono', 'SF Pro Text', 'SF Pro Display',
859
+ '.AppleSystemUIFont', 'Impact', 'Rockwell',
860
+ ]
861
+
862
+ /**
863
+ * Chinese names and their pinyin for the CJK families, so a search finds a
864
+ * font whether it is typed in Chinese or in pinyin/English.
865
+ */
866
+ const FONT_ALIASES = {
867
+ 'PingFang SC': { zh: '苹方-简 苹方', py: 'pingfang' },
868
+ 'PingFang HK': { zh: '苹方-港 苹方', py: 'pingfang' },
869
+ 'PingFang TC': { zh: '苹方-繁 苹方', py: 'pingfang' },
870
+ 'Hiragino Sans GB': { zh: '冬青黑体', py: 'dongqingheiti' },
871
+ 'Hiragino Sans': { zh: '冬青黑体', py: 'dongqingheiti' },
872
+ 'Heiti SC': { zh: '黑体-简 黑体', py: 'heiti' },
873
+ 'Songti SC': { zh: '宋体-简 宋体', py: 'songti' },
874
+ 'Kaiti SC': { zh: '楷体-简 楷体', py: 'kaiti' },
875
+ STHeiti: { zh: '华文黑体', py: 'huawenheiti' },
876
+ STSong: { zh: '华文宋体', py: 'huawensongti' },
877
+ STKaiti: { zh: '华文楷体', py: 'huawenkaiti' },
878
+ STFangsong: { zh: '华文仿宋', py: 'huawenfangsong' },
879
+ 'Yuanti SC': { zh: '圆体-简 圆体 幼圆', py: 'yuanti' },
880
+ 'Libian SC': { zh: '隶变-简 隶变', py: 'libian' },
881
+ 'Weibei SC': { zh: '魏碑-简 魏碑', py: 'weibei' },
882
+ 'Xingkai SC': { zh: '行楷-简 行楷', py: 'xingkai' },
883
+ 'Hannotate SC': { zh: '手札体-简 手札体', py: 'shouzhati' },
884
+ 'HanziPen SC': { zh: '翩翩体-简 翩翩体', py: 'pianpianiti' },
885
+ 'Wawati SC': { zh: '娃娃体-简 娃娃体', py: 'wawati' },
886
+ 'Baoli SC': { zh: '报隶-简 报隶', py: 'baoli' },
887
+ 'Lantinghei SC': { zh: '兰亭黑-简 兰亭黑', py: 'lantinghei' },
888
+ Fangsong: { zh: '仿宋', py: 'fangsong' },
889
+ 'Noto Sans SC': { zh: '思源黑体', py: 'siyuanheiti' },
890
+ 'Noto Serif SC': { zh: '思源宋体', py: 'siyuansongti' },
891
+ 'Source Han Sans SC': { zh: '思源黑体', py: 'siyuanheiti' },
892
+ 'Source Han Serif SC': { zh: '思源宋体', py: 'siyuansongti' },
893
+ }
894
+
895
+ /** Everything an entry can be searched by: label, native name, pinyin. */
896
+ function fontSearchText(family, extra) {
897
+ const alias = FONT_ALIASES[family]
898
+ let text = String(family).toLowerCase()
899
+ if (extra !== undefined && extra !== '') text += ' ' + String(extra).toLowerCase()
900
+ if (alias !== undefined) text += ' ' + alias.zh + ' ' + alias.py
901
+ return text
902
+ }
903
+
904
+ /** The weights offered for every family, in menu order. */
905
+ const FONT_WEIGHTS = [[400, 'Regular'], [300, 'Light'], [500, 'Medium'], [600, 'Semibold'], [700, 'Bold']]
906
+
907
+ /**
908
+ * How far the photo may travel for a given zoom: the percentages are of the
909
+ * layer's own size, so (zoom - 1) is the overflow and half of it each way.
910
+ */
911
+ function panPercent(position, zoomFactor) {
912
+ return ((50 - position) / 50) * ((zoomFactor - 1) * 50)
913
+ }
914
+
915
+ /** A CSS-safe family value: quoted, so dotted names still apply. */
916
+ function cssFamily(family) {
917
+ return '"' + String(family).replace(/["\\]/g, '') + '"'
918
+ }
919
+
920
+ /** `PingFang SC · Bold`, or just the family for the regular face. */
921
+ function fontLabel(family, weight) {
922
+ if (family === '') return ''
923
+ const hit = FONT_WEIGHTS.find(([value]) => value === weight)
924
+ return hit === undefined || weight === 400 ? family : family + ' · ' + hit[1]
925
+ }
926
+
927
+ let localFontsPromise = null
928
+
929
+ /** The local families, when Chromium's Local Font Access API is available. */
930
+ function loadLocalFonts() {
931
+ if (localFontsPromise !== null) return localFontsPromise
932
+ localFontsPromise = new Promise((resolve) => {
933
+ const query = typeof window === 'undefined' ? undefined : window.queryLocalFonts
934
+ if (typeof query !== 'function') {
935
+ resolve([])
936
+ return
937
+ }
938
+ try {
939
+ query.call(window).then((fonts) => {
940
+ const byFamily = new Map()
941
+ for (const font of fonts) {
942
+ const family = String(font.family)
943
+ const extra = [font.fullName, font.postscriptName].filter((part) => typeof part === 'string').join(' ')
944
+ byFamily.set(family, (byFamily.get(family) || '') + ' ' + extra)
945
+ }
946
+ const list = [...byFamily.entries()]
947
+ .map(([family, extra]) => ({ family, extra }))
948
+ .sort((left, right) => left.family.localeCompare(right.family))
949
+ resolve(list)
950
+ }).catch(() => { resolve([]) })
951
+ } catch {
952
+ resolve([])
953
+ }
954
+ })
955
+ return localFontsPromise
956
+ }
957
+
958
+ /**
959
+ * A font menu like the office suites: the last three choices on top, a rule,
960
+ * then every family the machine offers, each row drawn in its own face.
961
+ */
962
+ function FontPicker(props) {
963
+ const { t, value, weight, recent, onPick } = props
964
+ const [open, setOpen] = React.useState(false)
965
+ const [menuBox, setMenuBox] = React.useState(null)
966
+ const [fonts, setFonts] = React.useState(() => FALLBACK_FONTS.map((family) => ({ family, extra: '' })))
967
+ const [query, setQuery] = React.useState('')
968
+ const wrapRef = React.useRef(null)
969
+
970
+ const toggleMenu = () => {
971
+ if (open) {
972
+ setOpen(false)
973
+ return
974
+ }
975
+ const wrap = wrapRef.current
976
+ if (wrap === null || wrap === undefined) return
977
+ const rect = wrap.getBoundingClientRect()
978
+ const width = Math.max(180, rect.width)
979
+ const left = Math.max(8, Math.min(rect.left, window.innerWidth - width - 8))
980
+ const top = rect.bottom + 4
981
+ setMenuBox({ left, top, width, maxHeight: Math.max(120, window.innerHeight - top - 12) })
982
+ setQuery('')
983
+ setOpen(true)
984
+ }
985
+
986
+ React.useEffect(() => {
987
+ let alive = true
988
+ loadLocalFonts().then((list) => {
989
+ if (!alive || list.length === 0) return
990
+ setFonts(list)
991
+ })
992
+ return () => { alive = false }
993
+ }, [])
994
+
995
+ React.useEffect(() => {
996
+ if (!open) return
997
+ const onDown = (event) => {
998
+ const wrap = wrapRef.current
999
+ if (wrap !== null && wrap !== undefined && event.target instanceof Node && wrap.contains(event.target)) return
1000
+ setOpen(false)
1001
+ }
1002
+ document.addEventListener('pointerdown', onDown, true)
1003
+ return () => { document.removeEventListener('pointerdown', onDown, true) }
1004
+ }, [open])
1005
+
1006
+ const choose = (family, wide) => {
1007
+ onPick(family, wide)
1008
+ setOpen(false)
1009
+ }
1010
+ const label = value === '' ? t('fontDefault') : fontLabel(value, weight)
1011
+ const needle = query.trim().toLowerCase()
1012
+ // Every family offers its weight variants, so "Bold" is one entry away.
1013
+ const entries = []
1014
+ for (const record of fonts) {
1015
+ const haystack = fontSearchText(record.family, record.extra)
1016
+ for (const [value2, name] of FONT_WEIGHTS) {
1017
+ const label = fontLabel(record.family, value2)
1018
+ entries.push({ id: record.family + '|' + value2, family: record.family, weight: value2, label, haystack: haystack + ' ' + label.toLowerCase() })
1019
+ }
1020
+ }
1021
+ const matches = needle === '' ? entries : entries.filter((entry) => entry.haystack.includes(needle))
1022
+ const recentEntries = []
1023
+ for (const id of recent) {
1024
+ const parts = String(id).split('|')
1025
+ const family = parts[0]
1026
+ const w = Number(parts[1])
1027
+ if (family === '' || family === value && (Number.isFinite(w) ? w : 400) === (weight === '' ? 400 : Number(weight))) continue
1028
+ const entryLabel = fontLabel(family, Number.isFinite(w) ? w : 400)
1029
+ if (needle !== '' && !entryLabel.toLowerCase().includes(needle)) continue
1030
+ recentEntries.push({ id, family, weight: Number.isFinite(w) ? w : 400, label: entryLabel })
1031
+ }
1032
+
1033
+ return h(
1034
+ 'div',
1035
+ { className: 'sc-fontPicker', ref: wrapRef },
1036
+ h(
1037
+ 'button',
1038
+ {
1039
+ type: 'button',
1040
+ className: 'sc-fontBtn',
1041
+ 'aria-expanded': open ? 'true' : 'false',
1042
+ title: label,
1043
+ onClick: toggleMenu,
1044
+ },
1045
+ h('span', {
1046
+ className: 'sc-fontBtnLabel',
1047
+ style: value === '' ? undefined : { fontFamily: cssFamily(value), fontWeight: weight === '' ? 400 : Number(weight) },
1048
+ }, label),
1049
+ h('span', { className: 'sc-fontCaret', 'aria-hidden': 'true' }, '▾'),
1050
+ ),
1051
+ open
1052
+ ? h(
1053
+ 'div',
1054
+ {
1055
+ className: 'sc-fontMenu',
1056
+ role: 'listbox',
1057
+ style: menuBox === null
1058
+ ? undefined
1059
+ : {
1060
+ left: menuBox.left + 'px',
1061
+ top: menuBox.top + 'px',
1062
+ width: menuBox.width + 'px',
1063
+ maxHeight: menuBox.maxHeight + 'px',
1064
+ },
1065
+ },
1066
+ h(
1067
+ 'div',
1068
+ { className: 'sc-fontSearch' },
1069
+ h('input', {
1070
+ type: 'text',
1071
+ className: 'sc-textInput sc-fontSearchInput',
1072
+ placeholder: t('searchFont'),
1073
+ value: query,
1074
+ spellCheck: false,
1075
+ autoFocus: true,
1076
+ onChange: (event) => { setQuery(event.target.value) },
1077
+ onKeyDown: (event) => {
1078
+ if (event.key !== 'Escape') return
1079
+ event.preventDefault()
1080
+ event.stopPropagation()
1081
+ setOpen(false)
1082
+ },
1083
+ }),
1084
+ ),
1085
+ needle === ''
1086
+ ? h('button', { type: 'button', className: 'sc-fontItem sc-fontItemAuto', onClick: () => choose('', '') }, t('fontDefault'))
1087
+ : null,
1088
+ recentEntries.map((entry) => h(
1089
+ 'button',
1090
+ {
1091
+ key: 'recent-' + entry.id,
1092
+ type: 'button',
1093
+ className: 'sc-fontItem',
1094
+ style: { fontFamily: cssFamily(entry.family), fontWeight: entry.weight },
1095
+ onClick: () => choose(entry.family, entry.weight),
1096
+ },
1097
+ entry.label,
1098
+ )),
1099
+ recentEntries.length > 0 ? h('div', { className: 'sc-fontSep' }) : null,
1100
+ matches.map((entry) => h(
1101
+ 'button',
1102
+ {
1103
+ key: 'all-' + entry.id,
1104
+ type: 'button',
1105
+ className: 'sc-fontItem',
1106
+ style: { fontFamily: cssFamily(entry.family), fontWeight: entry.weight },
1107
+ onClick: () => choose(entry.family, entry.weight),
1108
+ },
1109
+ entry.label,
1110
+ )),
1111
+ matches.length === 0 ? h('div', { className: 'sc-fontEmpty' }, t('noFontMatch')) : null,
1112
+ )
1113
+ : null,
1114
+ )
1115
+ }
1116
+
413
1117
  function FolderGlyph({ size = 12 }) {
414
1118
  return h(
415
1119
  'svg',
@@ -667,6 +1371,7 @@ window.__ModuleLoader__.load({
667
1371
  const t = copyOf(props.t)
668
1372
  const isWide = wide !== false
669
1373
  const sharedState = useShared()
1374
+ const look = useSettings().draft
670
1375
  const buttonRef = React.useRef(null)
671
1376
 
672
1377
  const toggle = () => {
@@ -675,12 +1380,9 @@ window.__ModuleLoader__.load({
675
1380
  return
676
1381
  }
677
1382
  const element = buttonRef.current
678
- const rect = element === null || element === undefined
679
- ? { right: isWide ? 268 : 56 }
680
- : element.getBoundingClientRect()
681
1383
  // Only the horizontal anchor is needed: the card centres itself
682
1384
  // vertically in the frame.
683
- openWith({ right: rect.right }, element)
1385
+ openWith({ right: element === null || element === undefined ? (isWide ? 268 : 56) : sidebarEdgeRight(element) }, element)
684
1386
  }
685
1387
 
686
1388
  return h(
@@ -693,6 +1395,7 @@ window.__ModuleLoader__.load({
693
1395
  ref: buttonRef,
694
1396
  type: 'button',
695
1397
  className: isWide ? 'sc-launch' : 'sc-launch sc-launchRail',
1398
+ style: lookStyle(look),
696
1399
  'aria-label': t('open'),
697
1400
  'aria-expanded': sharedState.open ? 'true' : 'false',
698
1401
  'aria-haspopup': 'dialog',
@@ -727,6 +1430,7 @@ window.__ModuleLoader__.load({
727
1430
  const workspaceSnapshot = useWorkspaces((snapshot) => snapshot)
728
1431
  const created = useCreated()
729
1432
  const cardRef = React.useRef(null)
1433
+ const sideRef = React.useRef(null)
730
1434
  // Captured before the shared sheet clears its trigger on close.
731
1435
  const triggerRef = React.useRef(shared.trigger)
732
1436
  const todayKey = dayKeyOf(new Date())
@@ -756,7 +1460,16 @@ window.__ModuleLoader__.load({
756
1460
  && Array.isArray(workspaceSnapshot.items))
757
1461
  ? workspaceSnapshot.items.length
758
1462
  : 0
759
- const palette = React.useMemo(() => paletteFor(workspaceCount), [workspaceCount])
1463
+ const settings = useSettings()
1464
+ const look = settings.draft
1465
+ const palette = React.useMemo(() => paletteFor(workspaceCount, look.palette), [workspaceCount, look.palette])
1466
+ const [settingsOpen, setSettingsOpen] = React.useState(settingsPinned)
1467
+ const [pinned, setPinned] = React.useState(settingsPinned)
1468
+ const togglePin = () => {
1469
+ const next = !pinned
1470
+ settingsPinned = next
1471
+ setPinned(next)
1472
+ }
760
1473
  /** One Workspace's colour, or the quiet tertiary tone for an orphan group. */
761
1474
  const colorOf = (colorIndex) => (colorIndex >= 0 && palette[colorIndex] !== undefined
762
1475
  ? palette[colorIndex]
@@ -769,7 +1482,7 @@ window.__ModuleLoader__.load({
769
1482
  // Horizontally the card hugs the sidebar's right edge; vertically the
770
1483
  // stylesheet centres it in the frame with auto margins, so it never
771
1484
  // hands off the bottom of a short window.
772
- const wantedLeft = anchor === null || anchor === undefined ? 268 : anchor.right + 10
1485
+ const wantedLeft = anchor === null || anchor === undefined ? 268 : anchor.right
773
1486
  const left = Math.max(12, Math.min(wantedLeft, viewportWidth - width - 12))
774
1487
  // The height is fixed: switching to a day with more or fewer sessions
775
1488
  // must not resize the card, or the grid would slide under the pointer.
@@ -806,7 +1519,7 @@ window.__ModuleLoader__.load({
806
1519
  React.useEffect(() => {
807
1520
  const card = cardRef.current
808
1521
  if (card === null || card === undefined) return
809
- const selector = '.sc-navBtn, .sc-today, .sc-seg'
1522
+ const selector = '.sc-navBtn, .sc-today, .sc-seg, .sc-gearBtn'
810
1523
  let current = null
811
1524
  const clear = () => {
812
1525
  if (current === null) return
@@ -834,14 +1547,21 @@ window.__ModuleLoader__.load({
834
1547
  React.useEffect(() => {
835
1548
  const onPointerDown = (event) => {
836
1549
  const card = cardRef.current
1550
+ const side = sideRef.current
837
1551
  const target = event.target
838
1552
  if (card !== null && card !== undefined && target instanceof Node && card.contains(target)) return
1553
+ if (side !== null && side !== undefined && target instanceof Node && side.contains(target)) return
839
1554
  const trigger = shared.trigger
840
1555
  if (trigger !== null && trigger !== undefined && target instanceof Node && trigger.contains(target)) return
841
1556
  closeShared()
842
1557
  }
843
1558
  const onKeyDown = (event) => {
844
1559
  if (event.key !== 'Escape') return
1560
+ if (settingsOpen) {
1561
+ event.preventDefault()
1562
+ setSettingsOpen(false)
1563
+ return
1564
+ }
845
1565
  // Focus starts on the card, so a focused Escape belongs to it. When
846
1566
  // focus wandered outside, the page's own Escape handling stays intact.
847
1567
  const card = cardRef.current
@@ -859,7 +1579,7 @@ window.__ModuleLoader__.load({
859
1579
  document.removeEventListener('keydown', onKeyDown, true)
860
1580
  window.removeEventListener('resize', onResize)
861
1581
  }
862
- }, [])
1582
+ }, [settingsOpen])
863
1583
 
864
1584
  /**
865
1585
  * Arrow keys walk the selection: left/right by a day, up/down by a week.
@@ -874,7 +1594,8 @@ window.__ModuleLoader__.load({
874
1594
  const card = cardRef.current
875
1595
  if (card === null || card === undefined) return
876
1596
  const active = document.activeElement
877
- const inCard = active !== null && (active === card || card.contains(active))
1597
+ const side = sideRef.current
1598
+ const inCard = active !== null && (active === card || card.contains(active) || (side !== null && side !== undefined && side.contains(active)))
878
1599
  if (!inCard) return
879
1600
  if (active instanceof HTMLElement
880
1601
  && (active.tagName === 'INPUT' || active.tagName === 'TEXTAREA' || active.isContentEditable)) return
@@ -888,7 +1609,14 @@ window.__ModuleLoader__.load({
888
1609
  const parts = selected.split('-')
889
1610
  const next = new Date(Number(parts[0]), Number(parts[1]) - 1, Number(parts[2]) + step)
890
1611
  setSelected(dayKeyOf(next))
891
- if (!sameMonth(month, next)) setMonth(monthStartOf(next))
1612
+ if (!sameMonth(month, next)) {
1613
+ setMonth(monthStartOf(next))
1614
+ // The focused date button belongs to the month being replaced, so it
1615
+ // is unmounted and focus would fall back to the document body — the
1616
+ // next arrow key would then look like it came from outside the card.
1617
+ // Move focus to the card itself before the grid re-renders.
1618
+ card.focus({ preventScroll: true })
1619
+ }
892
1620
  }
893
1621
  document.addEventListener('keydown', onArrow)
894
1622
  return () => { document.removeEventListener('keydown', onArrow) }
@@ -931,7 +1659,83 @@ window.__ModuleLoader__.load({
931
1659
  weekday: t('weekday.' + selectedDate.getDay()),
932
1660
  })
933
1661
 
1662
+ // The look the reader picked: a plain colour wash or a local photo layered
1663
+ // under the card's own surface, plus the colour family below.
1664
+ const background = look.background
1665
+ // Zoom scales the layer, and the extra overflow is panned with a
1666
+ // translation: `background-position` alone can only move the photo along
1667
+ // the axis that `cover` actually crops, so a landscape photo in the tall
1668
+ // window could never be moved up or down.
1669
+ const zoomFactor = background.imageZoom / 100
1670
+ const panOf = (value) => panPercent(value, zoomFactor)
1671
+ // Photo mode keeps the same colour wash underneath, so the photo is
1672
+ // blended with the colour/opacity chosen in colour mode instead of the
1673
+ // theme surface (and dropping the wash altogether looked washed out).
1674
+ const washStyle = { background: 'color-mix(in srgb, ' + background.color + ' ' + background.alpha + '%, transparent)' }
1675
+ const backgroundStyle = background.mode === 'color'
1676
+ ? washStyle
1677
+ : {
1678
+ ...washStyle,
1679
+ '--sc-bg-image': background.image === '' ? 'none' : 'url("' + background.image + '")',
1680
+ '--sc-bg-alpha': String(background.imageAlpha / 100),
1681
+ '--sc-bg-x': background.imageX + '%',
1682
+ '--sc-bg-y': background.imageY + '%',
1683
+ '--sc-bg-zoom': String(zoomFactor),
1684
+ '--sc-bg-tx': panOf(background.imageX) + '%',
1685
+ '--sc-bg-ty': panOf(background.imageY) + '%',
1686
+ }
1687
+
1688
+ // The calendar and its look editor share one surface: the shell owns the
1689
+ // position, the background and the outer radius, so the two read as one
1690
+ // shape with a membrane in between rather than two cards side by side.
1691
+ const viewportWidth = typeof window === 'undefined' ? 1440 : window.innerWidth
1692
+ const PANEL_WIDTH = 300
1693
+ let panelWidth = 0
1694
+ let panelOnRight = true
1695
+ let shellLeft = geometry.left
1696
+ if (settingsOpen) {
1697
+ const roomRight = viewportWidth - (geometry.left + geometry.width) - 8
1698
+ const roomLeft = geometry.left - 8
1699
+ if (roomRight >= PANEL_WIDTH) {
1700
+ panelWidth = PANEL_WIDTH
1701
+ } else if (roomLeft >= PANEL_WIDTH) {
1702
+ panelWidth = PANEL_WIDTH
1703
+ panelOnRight = false
1704
+ shellLeft = geometry.left - PANEL_WIDTH
1705
+ } else {
1706
+ // Too narrow for a clean fusion: the editor overlays the seam with the
1707
+ // widest width that still fits, shrinking down to a usable minimum.
1708
+ panelWidth = Math.max(200, roomRight)
1709
+ panelOnRight = true
1710
+ }
1711
+ }
1712
+ const shellStyle = {
1713
+ left: shellLeft + 'px',
1714
+ width: (geometry.width + panelWidth) + 'px',
1715
+ height: geometry.height + 'px',
1716
+ ...backgroundStyle,
1717
+ ...lookStyle(look),
1718
+ }
1719
+
934
1720
  return h(
1721
+ 'div',
1722
+ {
1723
+ className: 'sc-shell',
1724
+ 'data-bg': background.mode,
1725
+ style: shellStyle,
1726
+ },
1727
+ panelOnRight
1728
+ ? null
1729
+ : h(SettingsPanel, {
1730
+ t,
1731
+ panelWidth,
1732
+ onRight: false,
1733
+ pinned,
1734
+ onTogglePin: togglePin,
1735
+ settings,
1736
+ panelRef: sideRef,
1737
+ }),
1738
+ h(
935
1739
  'div',
936
1740
  {
937
1741
  ref: cardRef,
@@ -939,15 +1743,17 @@ window.__ModuleLoader__.load({
939
1743
  className: 'sc-card',
940
1744
  role: 'dialog',
941
1745
  'data-mode': mode,
1746
+ 'data-bg': background.mode,
942
1747
  'aria-label': t('panel') + ' · ' + t('mode.' + mode),
943
1748
  tabIndex: -1,
944
- style: {
945
- left: geometry.left + 'px',
946
- width: geometry.width + 'px',
947
- height: geometry.height + 'px',
948
- },
949
1749
  },
950
- h('div', { className: 'sc-title' }, monthLabel),
1750
+ h(
1751
+ 'div',
1752
+ { className: 'sc-titleRow' },
1753
+ h('span', { className: 'sc-titleSpacer' }),
1754
+ h('span', { className: 'sc-title' }, monthLabel),
1755
+ h('span', { className: 'sc-titleSpacer' }),
1756
+ ),
951
1757
  h(
952
1758
  'header',
953
1759
  { className: 'sc-head' },
@@ -993,6 +1799,18 @@ window.__ModuleLoader__.load({
993
1799
  },
994
1800
  h(CloseGlyph),
995
1801
  ),
1802
+ h(
1803
+ 'button',
1804
+ {
1805
+ type: 'button',
1806
+ className: 'sc-gearBtn',
1807
+ 'aria-label': t('settings'),
1808
+ 'aria-expanded': settingsOpen ? 'true' : 'false',
1809
+ title: t('settings'),
1810
+ onClick: () => { setSettingsOpen(!settingsOpen) },
1811
+ },
1812
+ h(GearGlyph, { size: 14 }),
1813
+ ),
996
1814
  ),
997
1815
  h(
998
1816
  'div',
@@ -1146,47 +1964,688 @@ window.__ModuleLoader__.load({
1146
1964
  }),
1147
1965
  ),
1148
1966
  ),
1967
+ ),
1968
+ panelOnRight && settingsOpen
1969
+ ? h(SettingsPanel, {
1970
+ t,
1971
+ panelWidth,
1972
+ onRight: true,
1973
+ pinned,
1974
+ onTogglePin: togglePin,
1975
+ settings,
1976
+ panelRef: sideRef,
1977
+ })
1978
+ : null,
1149
1979
  )
1150
1980
  }
1151
1981
 
1152
- // ---------------------------------------------------------------------
1153
- // Styles. The row deliberately does NOT copy the two filled conversation
1154
- // buttons above it: it is a browsing tool, so it stays outlined and takes
1155
- // the calendar's accent instead of a raised fill. The card and the grid
1156
- // copy the host's floating-card and date-picker recipes, so both themes,
1157
- // the elevation hairline, and the backdrop material come from the page
1158
- // instead of from literals.
1159
- // ---------------------------------------------------------------------
1982
+ /**
1983
+ * The look editor, attached flush to the calendar's side.
1984
+ *
1985
+ * Two sections — the card's background (default surface, a colour wash or a
1986
+ * local photo, each with its own opacity) and the colour family every
1987
+ * Workspace colour is derived from — plus named profiles the reader can keep
1988
+ * and switch between. Edits apply live and persist as the working draft.
1989
+ */
1990
+ function SettingsPanel(props) {
1991
+ const { t, settings, panelRef, panelWidth, onRight, pinned, onTogglePin } = props
1992
+ const look = settings.draft
1993
+ const background = look.background
1994
+ const zoomFactor = background.imageZoom / 100
1995
+ const [nameDraft, setNameDraft] = React.useState('')
1996
+
1997
+ const patchBackground = (patch) => updateSettings((state) => ({
1998
+ ...state,
1999
+ draft: { ...state.draft, background: { ...state.draft.background, ...patch } },
2000
+ }))
2001
+ const patchPalette = (palette) => updateSettings((state) => ({
2002
+ ...state,
2003
+ draft: { ...state.draft, palette },
2004
+ }))
2005
+ const patchLook = (patch) => updateSettings((state) => ({
2006
+ ...state,
2007
+ draft: { ...state.draft, ...patch },
2008
+ }))
2009
+ // The swatch the reader last touched: "−" removes that one, so a middle
2010
+ // colour can be dropped without touching the ends.
2011
+ const [picked, setPicked] = React.useState(null)
2012
+ const padHoverRef = React.useRef(false)
2013
+ // Arrow keys work while the pointer is over the pad, not only when it has
2014
+ // focus; capture phase so the calendar's date keys never see them.
2015
+ React.useEffect(() => {
2016
+ const onKeyDown = (event) => {
2017
+ if (!padHoverRef.current) return
2018
+ if (event.altKey || event.ctrlKey || event.metaKey) return
2019
+ const delta = event.key === 'ArrowLeft' ? [1, 0]
2020
+ : event.key === 'ArrowRight' ? [-1, 0]
2021
+ : event.key === 'ArrowUp' ? [0, 1]
2022
+ : event.key === 'ArrowDown' ? [0, -1]
2023
+ : null
2024
+ if (delta === null) return
2025
+ event.preventDefault()
2026
+ event.stopPropagation()
2027
+ patchBackground({
2028
+ imageX: Math.max(0, Math.min(100, background.imageX + delta[0] * 2)),
2029
+ imageY: Math.max(0, Math.min(100, background.imageY + delta[1] * 2)),
2030
+ })
2031
+ }
2032
+ document.addEventListener('keydown', onKeyDown, true)
2033
+ return () => { document.removeEventListener('keydown', onKeyDown, true) }
2034
+ }, [background.imageX, background.imageY, background.mode])
1160
2035
 
1161
- const styles = `
1162
- /* Both seats name the same accent, so the row and the card it opens
1163
- share one colour. */
1164
- .sc-stack,
1165
- .sc-card {
1166
- /* The brand blue from DSH's own mark, at the owner's explicit request
1167
- for a brighter accent; it is one hue in both themes. */
1168
- --sc-calendar-accent: #4D6BFE;
2036
+ // The wheel has to be non-passive to keep the panel from scrolling, so it
2037
+ // is bound natively rather than through React's passive onWheel.
2038
+ React.useEffect(() => {
2039
+ const panel = panelRef.current
2040
+ if (panel === null || panel === undefined) return
2041
+ const onWheel = (event) => {
2042
+ const target = event.target
2043
+ if (!(target instanceof Element) || target.closest('.sc-pad') === null) return
2044
+ event.preventDefault()
2045
+ const step = event.deltaY < 0 ? 5 : -5
2046
+ const next = Math.max(100, Math.min(300, background.imageZoom + step))
2047
+ if (next !== background.imageZoom) patchBackground({ imageZoom: next })
2048
+ }
2049
+ panel.addEventListener('wheel', onWheel, { passive: false })
2050
+ return () => { panel.removeEventListener('wheel', onWheel) }
2051
+ }, [background.imageZoom, background.mode])
2052
+ // One compact slot: a label that resets the value, with the colour under it.
2053
+ /**
2054
+ * One compact slot: the caption, then the colour button with its own 默认
2055
+ * button beside it. The caption never resets anything — every colour has an
2056
+ * explicit control. `gradient` paints the caption with the colour family.
2057
+ */
2058
+ const swatchCell = (labelKey, field, fallback, reset, gradient) => h(
2059
+ 'div',
2060
+ { className: 'sc-tripleCell' },
2061
+ h('span', {
2062
+ className: 'sc-tripleLabel' + (gradient ? ' sc-tripleLabelGradient' : ''),
2063
+ style: gradient
2064
+ ? {
2065
+ backgroundImage: 'linear-gradient(90deg, ' + look.palette.join(', ') + ')',
2066
+ WebkitBackgroundClip: 'text',
2067
+ backgroundClip: 'text',
2068
+ color: 'transparent',
2069
+ WebkitTextFillColor: 'transparent',
2070
+ }
2071
+ : undefined,
2072
+ }, t(labelKey)),
2073
+ h(
2074
+ 'div',
2075
+ { className: 'sc-tripleRow' },
2076
+ h('input', {
2077
+ type: 'color',
2078
+ className: 'sc-colorInput sc-swatch sc-swatchSmall',
2079
+ value: look[field] === '' ? fallback : look[field],
2080
+ style: { background: look[field] === '' ? fallback : look[field] },
2081
+ onChange: (event) => { patchLook({ [field]: event.target.value.toUpperCase() }) },
2082
+ }),
2083
+ h('button', {
2084
+ type: 'button',
2085
+ className: 'sc-btn sc-btnTiny',
2086
+ title: t('resetValue'),
2087
+ onClick: () => { patchLook({ [field]: reset }) },
2088
+ }, t('bgDefault')),
2089
+ ),
2090
+ )
2091
+
2092
+ const movePicked = (delta) => {
2093
+ if (picked === null) return
2094
+ const to = picked + delta
2095
+ if (to < 0 || to >= look.palette.length) return
2096
+ const next = look.palette.slice()
2097
+ const moved = next.splice(picked, 1)[0]
2098
+ next.splice(to, 0, moved)
2099
+ patchPalette(next)
2100
+ setPicked(to)
2101
+ }
2102
+ const addPaletteColor = () => {
2103
+ if (look.palette.length >= 12) return
2104
+ patchPalette([...look.palette, look.palette[look.palette.length - 1]])
2105
+ setPicked(look.palette.length)
2106
+ }
2107
+ const removePaletteColor = () => {
2108
+ if (look.palette.length <= 2) return
2109
+ const at = picked !== null && picked >= 0 && picked < look.palette.length
2110
+ ? picked
2111
+ : look.palette.length - 1
2112
+ patchPalette(look.palette.filter((_, index) => index !== at))
2113
+ setPicked(null)
2114
+ }
2115
+ /** Colour mode starts from the surface in effect, never from black. */
2116
+ const switchToColor = () => {
2117
+ if (background.mode === 'color') return
2118
+ let color = background.color
2119
+ let alpha = background.alpha
2120
+ if (background.mode === 'default') {
2121
+ const panel = panelRef.current
2122
+ const shell = panel === null || panel === undefined || typeof panel.closest !== 'function'
2123
+ ? null
2124
+ : panel.closest('.sc-shell')
2125
+ const resolved = shell === null ? '' : window.getComputedStyle(shell).backgroundColor
2126
+ const parsed = parseCssColor(resolved)
2127
+ if (parsed !== null) {
2128
+ color = parsed.color
2129
+ alpha = parsed.alpha
2130
+ }
2131
+ }
2132
+ patchBackground({ mode: 'color', color, alpha })
2133
+ }
2134
+
2135
+ const pickImage = (event) => {
2136
+ const file = event.target.files !== null && event.target.files !== undefined ? event.target.files[0] : undefined
2137
+ if (file === undefined || file === null) return
2138
+ const reader = new FileReader()
2139
+ reader.onload = () => {
2140
+ const image = new Image()
2141
+ image.onload = () => {
2142
+ // Cap the stored photo rather than downscale it hard: the card is
2143
+ // 360 CSS px wide, but at 2x density and 300% zoom it can show about
2144
+ // 2160 device pixels, so 2400 keeps it sharp. WebP keeps that size
2145
+ // affordable in localStorage.
2146
+ const scale = Math.min(1, 2400 / Math.max(image.width, image.height))
2147
+ const canvas = document.createElement('canvas')
2148
+ canvas.width = Math.max(1, Math.round(image.width * scale))
2149
+ canvas.height = Math.max(1, Math.round(image.height * scale))
2150
+ const context = canvas.getContext('2d')
2151
+ if (context !== null) context.drawImage(image, 0, 0, canvas.width, canvas.height)
2152
+ const lossy = canvas.toDataURL('image/webp', 0.92)
2153
+ // Engines without WebP encoding silently return PNG; fall back to a
2154
+ // high-quality JPEG rather than storing a huge PNG.
2155
+ patchBackground({
2156
+ mode: 'image',
2157
+ image: lossy.startsWith('data:image/webp') ? lossy : canvas.toDataURL('image/jpeg', 0.9),
2158
+ })
2159
+ }
2160
+ image.src = String(reader.result)
2161
+ }
2162
+ reader.readAsDataURL(file)
1169
2163
  }
1170
- .sc-stack {
1171
- flex: 1 1 auto;
1172
- min-width: 0;
1173
- display: flex;
1174
- flex-direction: column;
1175
- gap: 6px;
2164
+
2165
+ const saveProfile = () => updateSettings((state) => ({
2166
+ ...state,
2167
+ profiles: { ...state.profiles, [state.active]: cloneLook(state.draft) },
2168
+ }))
2169
+ const saveAsProfile = () => {
2170
+ updateSettings((state) => {
2171
+ const name = nameDraft.trim() === '' ? t('untitledProfile') : nameDraft.trim()
2172
+ return { ...state, active: name, profiles: { ...state.profiles, [name]: cloneLook(state.draft) } }
2173
+ })
2174
+ setNameDraft('')
2175
+ }
2176
+ // Rename the profile in effect: the name field is the new name, and the
2177
+ // built-in default has no name of its own to change.
2178
+ const renameProfile = () => {
2179
+ const name = nameDraft.trim()
2180
+ if (name === '') return
2181
+ updateSettings((state) => {
2182
+ // The built-in look has no saved entry of its own, so renaming it
2183
+ // stores the current draft under the new name instead.
2184
+ const value = state.profiles[state.active] !== undefined
2185
+ ? cloneLook(state.profiles[state.active])
2186
+ : cloneLook(state.draft)
2187
+ const profiles = { ...state.profiles }
2188
+ delete profiles[state.active]
2189
+ profiles[name] = value
2190
+ return { ...state, active: name, profiles }
2191
+ })
2192
+ setNameDraft('')
1176
2193
  }
1177
- .sc-stackRail {
1178
- flex: none;
1179
- width: 36px;
1180
- gap: 4px;
2194
+ const removeProfile = () => updateSettings((state) => {
2195
+ const profiles = { ...state.profiles }
2196
+ delete profiles[state.active]
2197
+ return { ...state, active: '默认', profiles }
2198
+ })
2199
+ const switchProfile = (event) => {
2200
+ const name = event.target.value
2201
+ updateSettings((state) => ({
2202
+ ...state,
2203
+ active: name,
2204
+ draft: name === '默认'
2205
+ ? defaultSettings()
2206
+ : cloneLook(state.profiles[name] !== undefined ? state.profiles[name] : defaultSettings()),
2207
+ }))
1181
2208
  }
1182
- /* Unlike the two filled conversation buttons above it, this row is a
1183
- tool: outlined, unfilled, and accented with the calendar's own colour,
1184
- so its different purpose reads before its label does. */
1185
- /* Closed, the entry keeps the hairline outline of a button but stays
1186
- unfilled; open, it takes a light wash of the brand blue, so the colour
1187
- means "this calendar is showing" rather than decorating the row. */
1188
- .sc-launch {
1189
- display: flex;
2209
+
2210
+ const profileNames = ['默认', ...Object.keys(settings.profiles).filter((name) => name !== '默认')]
2211
+
2212
+ return h(
2213
+ 'aside',
2214
+ {
2215
+ ref: panelRef,
2216
+ className: onRight ? 'sc-side' : 'sc-side sc-sideLeft',
2217
+ role: 'dialog',
2218
+ 'aria-label': t('settings'),
2219
+ 'data-bg': background.mode,
2220
+ style: { width: panelWidth + 'px' },
2221
+ },
2222
+ h(
2223
+ 'div',
2224
+ { className: 'sc-sideHead' },
2225
+ h('span', { className: 'sc-sideTitle' }, t('settings')),
2226
+ h('button', {
2227
+ type: 'button',
2228
+ className: 'sc-pinBtn',
2229
+ 'aria-pressed': pinned ? 'true' : 'false',
2230
+ 'aria-label': pinned ? t('unpin') : t('pin'),
2231
+ title: pinned ? t('unpin') : t('pin'),
2232
+ onClick: onTogglePin,
2233
+ }, h(PinGlyph, { size: 13 })),
2234
+ ),
2235
+ h(
2236
+ 'div',
2237
+ { className: 'sc-sideBody' },
2238
+ // ---- the sidebar entry, first because it sits outside the calendar ----
2239
+ h('section', { className: 'sc-section' },
2240
+ h('div', { className: 'sc-sectionTitle' }, t('pluginButton')),
2241
+ h('div', { className: 'sc-triple sc-triple2' },
2242
+ swatchCell('launchIcon', 'launchIcon', '#4D6BFE', ''),
2243
+ swatchCell('launchText', 'launchText', '#808080', ''),
2244
+ swatchCell('launchBorder', 'launchBorder', '#808080', ''),
2245
+ swatchCell('launchBg', 'launchBg', '#808080', ''),
2246
+ ),
2247
+ ),
2248
+ // ---- background ----
2249
+ h('section', { className: 'sc-section' },
2250
+ h('div', { className: 'sc-sectionTitle' }, t('background')),
2251
+ h(
2252
+ 'div',
2253
+ { className: 'sc-tabs' },
2254
+ [['color', t('bgColor')], ['image', t('bgImage')]].map(([value, label]) => h(
2255
+ 'button',
2256
+ {
2257
+ key: value,
2258
+ type: 'button',
2259
+ className: 'sc-tab',
2260
+ 'aria-pressed': background.mode === value ? 'true' : 'false',
2261
+ onClick: () => { if (value === 'color') switchToColor(); else { patchBackground({ mode: value }) } },
2262
+ },
2263
+ label,
2264
+ )),
2265
+ ),
2266
+ background.mode === 'color'
2267
+ ? h(
2268
+ React.Fragment,
2269
+ null,
2270
+ h('div', { className: 'sc-field' },
2271
+ h('span', { className: 'sc-label' }, t('color')),
2272
+ h('input', {
2273
+ type: 'color',
2274
+ className: 'sc-colorInput',
2275
+ value: background.color,
2276
+ style: { background: background.color },
2277
+ onChange: (event) => { patchBackground({ color: event.target.value.toUpperCase() }) },
2278
+ }),
2279
+ h('button', {
2280
+ type: 'button',
2281
+ className: 'sc-btn sc-btnTiny',
2282
+ title: t('bgDefault'),
2283
+ onClick: () => { patchBackground({ mode: 'default' }) },
2284
+ }, t('bgDefault')),
2285
+ ),
2286
+ h('label', { className: 'sc-field' },
2287
+ h('span', { className: 'sc-label' }, t('opacity')),
2288
+ h('input', {
2289
+ type: 'range',
2290
+ className: 'sc-range',
2291
+ min: 0,
2292
+ max: 100,
2293
+ value: background.alpha,
2294
+ onChange: (event) => { patchBackground({ alpha: Number(event.target.value) }) },
2295
+ }),
2296
+ h('span', { className: 'sc-value' }, background.alpha + '%'),
2297
+ ),
2298
+ )
2299
+ : null,
2300
+ background.mode === 'image'
2301
+ ? h(
2302
+ React.Fragment,
2303
+ null,
2304
+ background.image === ''
2305
+ ? h('label', { className: 'sc-filePick' },
2306
+ h('span', null, t('pickImage')),
2307
+ h('input', { type: 'file', accept: 'image/*', className: 'sc-fileHidden', onChange: pickImage }),
2308
+ )
2309
+ : h(
2310
+ React.Fragment,
2311
+ null,
2312
+ h('div', { className: 'sc-photoRow' },
2313
+ h('label', {
2314
+ className: 'sc-photo',
2315
+ title: t('replaceImage'),
2316
+ style: { backgroundImage: 'url("' + background.image + '")' },
2317
+ },
2318
+ h('input', { type: 'file', accept: 'image/*', className: 'sc-fileHidden', onChange: pickImage }),
2319
+ ),
2320
+ h('div', {
2321
+ className: 'sc-pad',
2322
+ title: t('photoPositionHint'),
2323
+ 'aria-label': t('photoPositionHint'),
2324
+ tabIndex: 0,
2325
+ onPointerEnter: () => { padHoverRef.current = true },
2326
+ onPointerLeave: () => { padHoverRef.current = false },
2327
+ onKeyDown: (event) => {
2328
+ // `background-position` runs opposite to the visual
2329
+ // direction, so left/up add and right/down subtract.
2330
+ const delta = event.key === 'ArrowLeft' ? [1, 0]
2331
+ : event.key === 'ArrowRight' ? [-1, 0]
2332
+ : event.key === 'ArrowUp' ? [0, 1]
2333
+ : event.key === 'ArrowDown' ? [0, -1]
2334
+ : null
2335
+ if (delta === null) return
2336
+ event.preventDefault()
2337
+ event.stopPropagation()
2338
+ patchBackground({
2339
+ imageX: Math.max(0, Math.min(100, background.imageX + delta[0] * 2)),
2340
+ imageY: Math.max(0, Math.min(100, background.imageY + delta[1] * 2)),
2341
+ })
2342
+ },
2343
+ onPointerDown: (event) => {
2344
+ event.preventDefault()
2345
+ const pad = event.currentTarget
2346
+ if (typeof pad.setPointerCapture === 'function') {
2347
+ try { pad.setPointerCapture(event.pointerId) } catch { /* best effort */ }
2348
+ }
2349
+ const rect = pad.getBoundingClientRect()
2350
+ const startX = event.clientX
2351
+ const startY = event.clientY
2352
+ const fromX = background.imageX
2353
+ const fromY = background.imageY
2354
+ const clamp = (value) => Math.max(0, Math.min(100, value))
2355
+ // Relative drag: the photo moves with the pointer from
2356
+ // wherever it is; a plain click leaves it alone. The
2357
+ // values are mirrored because `background-position`
2358
+ // moves the photo the other way round.
2359
+ let dragging = false
2360
+ const onMove = (moveEvent) => {
2361
+ const dx = moveEvent.clientX - startX
2362
+ const dy = moveEvent.clientY - startY
2363
+ if (!dragging && Math.abs(dx) < 2 && Math.abs(dy) < 2) return
2364
+ dragging = true
2365
+ patchBackground({
2366
+ imageX: Math.round(clamp(fromX - (dx / rect.width) * 100)),
2367
+ imageY: Math.round(clamp(fromY - (dy / rect.height) * 100)),
2368
+ })
2369
+ }
2370
+ const onUp = () => {
2371
+ window.removeEventListener('pointermove', onMove)
2372
+ window.removeEventListener('pointerup', onUp)
2373
+ }
2374
+ window.addEventListener('pointermove', onMove)
2375
+ window.addEventListener('pointerup', onUp)
2376
+ },
2377
+ },
2378
+ h('span', {
2379
+ className: 'sc-padLayer',
2380
+ style: {
2381
+ backgroundImage: 'url("' + background.image + '")',
2382
+ backgroundPosition: background.imageX + '% ' + background.imageY + '%',
2383
+ transform: 'translate(' + panPercent(background.imageX, zoomFactor) + '%, ' + panPercent(background.imageY, zoomFactor) + '%) scale(' + zoomFactor + ')',
2384
+ },
2385
+ }),
2386
+ h('button', {
2387
+ type: 'button',
2388
+ className: 'sc-padReset',
2389
+ title: t('resetPosition'),
2390
+ 'aria-label': t('resetPosition'),
2391
+ onPointerDown: (event) => { event.stopPropagation() },
2392
+ onClick: (event) => {
2393
+ event.stopPropagation()
2394
+ patchBackground({ imageX: 50, imageY: 50 })
2395
+ },
2396
+ }, '↺'),
2397
+ ),
2398
+ ),
2399
+ h('label', { className: 'sc-field' },
2400
+ h('span', { className: 'sc-label' }, t('zoom')),
2401
+ h('input', {
2402
+ type: 'range',
2403
+ className: 'sc-range',
2404
+ min: 100,
2405
+ max: 300,
2406
+ step: 5,
2407
+ value: background.imageZoom,
2408
+ onChange: (event) => { patchBackground({ imageZoom: Number(event.target.value) }) },
2409
+ }),
2410
+ h('span', { className: 'sc-value' }, background.imageZoom + '%'),
2411
+ ),
2412
+ h('label', { className: 'sc-field' },
2413
+ h('span', { className: 'sc-label' }, t('opacity')),
2414
+ h('input', {
2415
+ type: 'range',
2416
+ className: 'sc-range',
2417
+ min: 0,
2418
+ max: 100,
2419
+ value: background.imageAlpha,
2420
+ onChange: (event) => { patchBackground({ imageAlpha: Number(event.target.value) }) },
2421
+ }),
2422
+ h('span', { className: 'sc-value' }, background.imageAlpha + '%'),
2423
+ ),
2424
+ h('button', {
2425
+ type: 'button',
2426
+ className: 'sc-btn',
2427
+ // Drop only the photo: the reader stays in photo mode and
2428
+ // can pick another one straight away.
2429
+ onClick: () => { patchBackground({ image: '' }) },
2430
+ }, t('removeImage')),
2431
+ ),
2432
+ )
2433
+ : null,
2434
+ ),
2435
+ // ---- theme colours: the three colours share one row ----------
2436
+ h('section', { className: 'sc-section' },
2437
+ h('div', { className: 'sc-sectionTitle' }, t('theme')),
2438
+ h('div', { className: 'sc-triple' },
2439
+ swatchCell('textColor', 'text', '#808080', '', true),
2440
+ swatchCell('borderColor', 'border', '#808080', ''),
2441
+ swatchCell('accentColor', 'accent', '#4D6BFE', DEFAULT_ACCENT),
2442
+ ),
2443
+ h('div', { className: 'sc-cell2 sc-cell2Wide' },
2444
+ h(FontPicker, {
2445
+ t,
2446
+ value: look.font,
2447
+ weight: look.fontWeight,
2448
+ recent: look.fontRecent,
2449
+ onPick: (family, pickedWeight) => {
2450
+ if (family === '') {
2451
+ patchLook({ font: '', fontWeight: '' })
2452
+ return
2453
+ }
2454
+ const id = family + '|' + pickedWeight
2455
+ const nextRecent = [id, ...look.fontRecent.filter((entry) => entry !== id)].slice(0, 3)
2456
+ patchLook({ font: family, fontWeight: String(pickedWeight), fontRecent: nextRecent })
2457
+ },
2458
+ }),
2459
+ ),
2460
+ ),
2461
+ // ---- colour family ----
2462
+ h('section', { className: 'sc-section sc-sectionPalette' },
2463
+ h(
2464
+ 'div',
2465
+ { className: 'sc-sectionHead' },
2466
+ h('span', { className: 'sc-sectionTitle' }, t('palette')),
2467
+ h('button', {
2468
+ type: 'button',
2469
+ className: 'sc-iconBtn sc-iconBtnAdd',
2470
+ 'aria-label': t('addColor'),
2471
+ title: t('addColor'),
2472
+ disabled: look.palette.length >= 12,
2473
+ onClick: addPaletteColor,
2474
+ }, '+'),
2475
+ h('button', {
2476
+ type: 'button',
2477
+ className: 'sc-iconBtn',
2478
+ 'aria-label': t('removeColor'),
2479
+ title: t('removeColor'),
2480
+ disabled: look.palette.length <= 2,
2481
+ onClick: removePaletteColor,
2482
+ }, '−'),
2483
+ h('button', {
2484
+ type: 'button',
2485
+ className: 'sc-iconBtn',
2486
+ 'aria-label': t('moveLeft'),
2487
+ title: t('moveLeft'),
2488
+ disabled: picked === null || picked <= 0,
2489
+ onClick: () => { movePicked(-1) },
2490
+ }, h(ChevronGlyph, { size: 12, direction: 'left' })),
2491
+ h('button', {
2492
+ type: 'button',
2493
+ className: 'sc-iconBtn',
2494
+ 'aria-label': t('moveRight'),
2495
+ title: t('moveRight'),
2496
+ disabled: picked === null || picked >= look.palette.length - 1,
2497
+ onClick: () => { movePicked(1) },
2498
+ }, h(ChevronGlyph, { size: 12, direction: 'right' })),
2499
+ ),
2500
+ h('div', { className: 'sc-paletteLine' },
2501
+ h('div', { className: 'sc-palette' }, look.palette.map((color, index) => h(
2502
+ 'div',
2503
+ // The key must not contain the colour: a changing key remounts the
2504
+ // row and macOS closes the colour panel the drag is happening in.
2505
+ {
2506
+ key: index,
2507
+ className: 'sc-paletteRow' + (picked === index ? ' sc-paletteRowPicked' : ''),
2508
+ onPointerDown: () => { setPicked(index) },
2509
+ },
2510
+ h('input', {
2511
+ type: 'color',
2512
+ className: 'sc-colorInput sc-swatch',
2513
+ value: color,
2514
+ title: color,
2515
+ style: { background: color },
2516
+ onChange: (event) => {
2517
+ const next = look.palette.slice()
2518
+ next[index] = event.target.value.toUpperCase()
2519
+ patchPalette(next)
2520
+ },
2521
+ }),
2522
+ ))),
2523
+ h('button', {
2524
+ type: 'button',
2525
+ className: 'sc-btn sc-btnTiny sc-paletteReset',
2526
+ title: t('resetPalette'),
2527
+ onClick: () => { patchPalette(PALETTE.slice()); setPicked(null) },
2528
+ }, t('resetPalette')),
2529
+ ),
2530
+ ),
2531
+ // ---- profiles ----
2532
+ h('section', { className: 'sc-section' },
2533
+ h('div', { className: 'sc-sectionTitle' }, t('profiles')),
2534
+ h('select', { className: 'sc-select', value: settings.active, onChange: switchProfile },
2535
+ profileNames.map((name) => h('option', { key: name, value: name }, name))),
2536
+ h('div', { className: 'sc-panelRow' },
2537
+ h('input', {
2538
+ type: 'text',
2539
+ className: 'sc-textInput',
2540
+ placeholder: t('profileName'),
2541
+ value: nameDraft,
2542
+ onChange: (event) => { setNameDraft(event.target.value) },
2543
+ }),
2544
+ h('button', {
2545
+ type: 'button',
2546
+ className: 'sc-btn',
2547
+ disabled: look === undefined,
2548
+ onClick: saveAsProfile,
2549
+ }, t('saveAsProfile')),
2550
+ ),
2551
+ h('div', { className: 'sc-panelRow' },
2552
+ h('button', {
2553
+ type: 'button',
2554
+ className: 'sc-btn',
2555
+ onClick: saveProfile,
2556
+ }, t('saveProfile')),
2557
+ h('button', {
2558
+ type: 'button',
2559
+ className: 'sc-btn',
2560
+ disabled: nameDraft.trim() === '',
2561
+ title: t('renameProfile'),
2562
+ onClick: renameProfile,
2563
+ }, t('renameProfile')),
2564
+ h('button', {
2565
+ type: 'button',
2566
+ className: 'sc-btn',
2567
+ disabled: settings.active === '默认',
2568
+ onClick: removeProfile,
2569
+ }, t('deleteProfile')),
2570
+ ),
2571
+ ),
2572
+ ),
2573
+ )
2574
+ }
2575
+
2576
+ // ---------------------------------------------------------------------
2577
+ // Styles. The row deliberately does NOT copy the two filled conversation
2578
+ // buttons above it: it is a browsing tool, so it stays outlined and takes
2579
+ // the calendar's accent instead of a raised fill. The card and the grid
2580
+ // copy the host's floating-card and date-picker recipes, so both themes,
2581
+ // the elevation hairline, and the backdrop material come from the page
2582
+ // instead of from literals.
2583
+ // ---------------------------------------------------------------------
2584
+
2585
+ const styles = `
2586
+ /* Text should sit in the same place whichever family is chosen. Every
2587
+ font puts a different amount of space above the cap height and below
2588
+ the baseline, and a centred box then pushes the glyphs up or down.
2589
+ Trimming the line box to cap-height/baseline makes that space zero, so
2590
+ centring becomes family-independent. Engines without the property
2591
+ simply ignore it. */
2592
+ .sc-shell,
2593
+ .sc-shell *,
2594
+ .sc-stack button {
2595
+ text-box-trim: trim-both;
2596
+ text-box-edge: cap alphabetic;
2597
+ }
2598
+ /* The font list previews keep their natural leading: trimming squeezed
2599
+ the rows on top of each other. */
2600
+ .sc-fontPicker,
2601
+ .sc-fontPicker *,
2602
+ .sc-fontMenu,
2603
+ .sc-fontMenu * {
2604
+ text-box-trim: none;
2605
+ text-box-edge: auto;
2606
+ }
2607
+ /* Single-line labels clip themselves for the ellipsis, and a trimmed
2608
+ line box is shorter than a CJK glyph, so the top and bottom of the
2609
+ characters were being cut off. These keep their natural box; a
2610
+ sub-pixel drift per family is invisible at this size. */
2611
+ .sc-tripleLabel,
2612
+ .sc-cell2Label,
2613
+ .sc-launchLabel,
2614
+ .sc-title,
2615
+ .sc-dayLabel,
2616
+ .sc-groupTitle,
2617
+ .sc-rowTitle,
2618
+ .sc-sectionTitle,
2619
+ .sc-fontBtnLabel {
2620
+ text-box-trim: none;
2621
+ text-box-edge: auto;
2622
+ }
2623
+ .sc-fontItem {
2624
+ line-height: 1.6;
2625
+ }
2626
+ /* The brand blue from DSH's own mark, at the owner's explicit request for
2627
+ a brighter accent; it is one hue in both themes. Each seat's container
2628
+ can override it inline when the reader picks another colour. */
2629
+ .sc-stack {
2630
+ flex: 1 1 auto;
2631
+ min-width: 0;
2632
+ display: flex;
2633
+ flex-direction: column;
2634
+ gap: 6px;
2635
+ }
2636
+ .sc-stackRail {
2637
+ flex: none;
2638
+ width: 36px;
2639
+ gap: 4px;
2640
+ }
2641
+ /* Unlike the two filled conversation buttons above it, this row is a
2642
+ tool: outlined, unfilled, and accented with the calendar's own colour,
2643
+ so its different purpose reads before its label does. */
2644
+ /* Closed, the entry keeps the hairline outline of a button but stays
2645
+ unfilled; open, it takes a light wash of the brand blue, so the colour
2646
+ means "this calendar is showing" rather than decorating the row. */
2647
+ .sc-launch {
2648
+ display: flex;
1190
2649
  align-items: center;
1191
2650
  justify-content: center;
1192
2651
  gap: 6px;
@@ -1195,25 +2654,24 @@ window.__ModuleLoader__.load({
1195
2654
  padding: 8px 12px;
1196
2655
  margin: 0;
1197
2656
  box-sizing: border-box;
1198
- border: 1px solid var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12));
2657
+ border: 1px solid var(--sc-launch-border, var(--sc-border, var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12))));
1199
2658
  border-radius: var(--dsw-radius-md, 10px);
1200
- background: transparent;
1201
- color: var(--dsw-alias-label-primary);
2659
+ background: var(--sc-launch-bg, transparent);
2660
+ color: var(--sc-launch-text, var(--sc-text-strong, var(--dsw-alias-label-primary)));
1202
2661
  font: inherit;
1203
2662
  font-size: 14px;
1204
2663
  font-weight: 500;
1205
- line-height: 22px;
1206
2664
  white-space: nowrap;
1207
2665
  cursor: pointer;
1208
2666
  overflow: hidden;
1209
2667
  }
1210
2668
  .sc-launch svg {
1211
2669
  flex: none;
1212
- color: var(--sc-calendar-accent);
2670
+ color: var(--sc-launch-icon, var(--sc-calendar-accent));
1213
2671
  }
1214
2672
  .sc-launch[aria-expanded='true'] {
1215
- border-color: color-mix(in srgb, var(--sc-calendar-accent) 45%, transparent);
1216
- background: color-mix(in srgb, var(--sc-calendar-accent) 15%, transparent);
2673
+ border-color: var(--sc-launch-border, color-mix(in srgb, var(--sc-calendar-accent) 45%, transparent));
2674
+ background: var(--sc-launch-bg, color-mix(in srgb, var(--sc-calendar-accent) 15%, transparent));
1217
2675
  }
1218
2676
  .sc-launch:focus-visible {
1219
2677
  outline: 2px solid var(--dsw-focus-ring-color, var(--sc-calendar-accent));
@@ -1230,6 +2688,593 @@ window.__ModuleLoader__.load({
1230
2688
  height: 36px;
1231
2689
  padding: 0;
1232
2690
  }
2691
+ /* The look editor: a second column of the same surface, divided from the
2692
+ calendar by a hairline membrane. */
2693
+ .sc-side {
2694
+ position: relative;
2695
+ z-index: 0;
2696
+ flex: none;
2697
+ display: flex;
2698
+ flex-direction: column;
2699
+ height: 100%;
2700
+ box-sizing: border-box;
2701
+ border-left: 0.5px solid var(--sc-border, var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12)));
2702
+ background: transparent;
2703
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
2704
+ font-size: 12.5px;
2705
+ overflow: hidden;
2706
+ }
2707
+ .sc-sideLeft {
2708
+ border-left: 0;
2709
+ border-right: 0.5px solid var(--sc-border, var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12)));
2710
+ }
2711
+ .sc-sideHead {
2712
+ flex: none;
2713
+ display: flex;
2714
+ align-items: center;
2715
+ gap: 6px;
2716
+ padding: 5px 10px;
2717
+ border-bottom: 0.5px solid var(--sc-border, var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12)));
2718
+ }
2719
+ .sc-sideTitle {
2720
+ flex: 1 1 auto;
2721
+ font-size: 13px;
2722
+ font-weight: 600;
2723
+ }
2724
+ .sc-pinBtn {
2725
+ flex: none;
2726
+ display: inline-flex;
2727
+ align-items: center;
2728
+ justify-content: center;
2729
+ width: 24px;
2730
+ height: 24px;
2731
+ padding: 0;
2732
+ border: 0;
2733
+ border-radius: 6px;
2734
+ background: transparent;
2735
+ color: var(--sc-text-dim, var(--dsw-alias-label-tertiary));
2736
+ cursor: pointer;
2737
+ }
2738
+ .sc-pinBtn:hover {
2739
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 9%, transparent);
2740
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
2741
+ }
2742
+ .sc-pinBtn[aria-pressed='true'] {
2743
+ background: color-mix(in srgb, var(--sc-calendar-accent) 16%, transparent);
2744
+ color: var(--sc-calendar-accent);
2745
+ }
2746
+ .sc-sideBody {
2747
+ flex: 1 1 auto;
2748
+ min-height: 0;
2749
+ /* The editor never shows a scrollbar, but the wheel still reaches the
2750
+ last section on a short window instead of clipping it. */
2751
+ overflow-y: auto;
2752
+ scrollbar-width: none;
2753
+ padding: 2px 10px 8px;
2754
+ display: flex;
2755
+ flex-direction: column;
2756
+ gap: 8px;
2757
+ }
2758
+ .sc-sideBody::-webkit-scrollbar {
2759
+ width: 0;
2760
+ height: 0;
2761
+ }
2762
+ /* The colour list scrolls sideways, not the editor: it keeps its own
2763
+ height like every other section. */
2764
+ .sc-sectionPalette {
2765
+ flex: none;
2766
+ }
2767
+ .sc-section {
2768
+ display: flex;
2769
+ flex-direction: column;
2770
+ gap: 5px;
2771
+ padding-top: 6px;
2772
+ border-top: 0.5px solid var(--sc-border, var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12)));
2773
+ }
2774
+ .sc-section:first-child {
2775
+ border-top: 0;
2776
+ padding-top: 2px;
2777
+ }
2778
+ .sc-sectionHead {
2779
+ display: flex;
2780
+ align-items: center;
2781
+ gap: 4px;
2782
+ }
2783
+ .sc-sectionHead .sc-sectionTitle {
2784
+ flex: 1 1 auto;
2785
+ }
2786
+ .sc-sectionHead .sc-iconBtn {
2787
+ width: 20px;
2788
+ height: 20px;
2789
+ font-size: 14px;
2790
+ }
2791
+ .sc-sectionTitle {
2792
+ font-size: 13px;
2793
+ font-weight: 600;
2794
+ letter-spacing: 0.01em;
2795
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
2796
+ text-transform: none;
2797
+ }
2798
+ .sc-tabs {
2799
+ display: flex;
2800
+ gap: 2px;
2801
+ padding: 2px;
2802
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
2803
+ border-radius: 8px;
2804
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 5%, transparent);
2805
+ }
2806
+ .sc-tab {
2807
+ flex: 1 1 0;
2808
+ min-height: 24px;
2809
+ padding: 0 6px;
2810
+ border: 0;
2811
+ border-radius: 6px;
2812
+ background: transparent;
2813
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
2814
+ font: inherit;
2815
+ font-size: 12px;
2816
+ cursor: pointer;
2817
+ }
2818
+ .sc-tab[aria-pressed='true'] {
2819
+ background: color-mix(in srgb, var(--sc-calendar-accent) 16%, transparent);
2820
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
2821
+ font-weight: 600;
2822
+ }
2823
+ .sc-field .sc-colorInput {
2824
+ width: 34px;
2825
+ height: 24px;
2826
+ }
2827
+ .sc-field {
2828
+ display: flex;
2829
+ align-items: center;
2830
+ gap: 8px;
2831
+ }
2832
+ .sc-label {
2833
+ flex: none;
2834
+ min-width: 52px;
2835
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
2836
+ }
2837
+ .sc-value {
2838
+ flex: none;
2839
+ min-width: 38px;
2840
+ text-align: right;
2841
+ font-variant-numeric: tabular-nums;
2842
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
2843
+ }
2844
+ /* Every colour control is framed: the swatch still fills the inside. */
2845
+ .sc-colorInput {
2846
+ flex: none;
2847
+ width: 30px;
2848
+ height: 24px;
2849
+ padding: 0;
2850
+ box-sizing: border-box;
2851
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
2852
+ border-radius: 7px;
2853
+ background: none;
2854
+ cursor: pointer;
2855
+ -webkit-appearance: none;
2856
+ appearance: none;
2857
+ }
2858
+ .sc-colorInput:hover {
2859
+ border-color: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 35%, transparent);
2860
+ }
2861
+ .sc-colorInput::-webkit-color-swatch-wrapper {
2862
+ padding: 0;
2863
+ }
2864
+ /* The colour is drawn as the input's own background, so it fills exactly
2865
+ the border's shape; the native swatch is only the click target. */
2866
+ .sc-colorInput::-webkit-color-swatch {
2867
+ border: 0;
2868
+ border-radius: inherit;
2869
+ opacity: 0;
2870
+ }
2871
+ /* Same box as the 默认 button beside it: height, radius and frame match. */
2872
+ .sc-swatch {
2873
+ width: 26px;
2874
+ height: 24px;
2875
+ border-radius: 7px;
2876
+ }
2877
+ .sc-textInput {
2878
+ flex: 1 1 auto;
2879
+ min-width: 0;
2880
+ height: 24px;
2881
+ padding: 0 8px;
2882
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
2883
+ border-radius: 6px;
2884
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 4%, transparent);
2885
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
2886
+ font: inherit;
2887
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
2888
+ font-size: 11.5px;
2889
+ }
2890
+ .sc-range {
2891
+ flex: 1 1 auto;
2892
+ min-width: 0;
2893
+ accent-color: var(--sc-calendar-accent);
2894
+ }
2895
+ /* The picker is our own button; the native control stays off-screen, so
2896
+ its "no file chosen" line never shows. */
2897
+ .sc-filePick {
2898
+ display: flex;
2899
+ align-items: center;
2900
+ justify-content: center;
2901
+ width: 100%;
2902
+ min-height: 26px;
2903
+ padding: 3px 10px;
2904
+ box-sizing: border-box;
2905
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.12)));
2906
+ border-radius: 7px;
2907
+ background: transparent;
2908
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
2909
+ font-size: 12px;
2910
+ cursor: pointer;
2911
+ }
2912
+ .sc-filePick:hover {
2913
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 8%, transparent);
2914
+ }
2915
+ .sc-fileHidden {
2916
+ display: none;
2917
+ }
2918
+ .sc-photoRow {
2919
+ display: flex;
2920
+ align-items: center;
2921
+ gap: 8px;
2922
+ }
2923
+ .sc-photo {
2924
+ position: relative;
2925
+ flex: 1 1 auto;
2926
+ display: block;
2927
+ height: 84px;
2928
+ box-sizing: border-box;
2929
+ overflow: hidden;
2930
+ cursor: pointer;
2931
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
2932
+ border-radius: 8px;
2933
+ /* The thumbnail is a still frame: filled and centred, never panned. */
2934
+ background-size: cover;
2935
+ background-position: center;
2936
+ background-repeat: no-repeat;
2937
+ }
2938
+ /* Drag pad: the same photo, smaller; the dot is where the photo is
2939
+ anchored inside the frame. */
2940
+ .sc-pad {
2941
+ position: relative;
2942
+ flex: none;
2943
+ width: 84px;
2944
+ height: 84px;
2945
+ box-sizing: border-box;
2946
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
2947
+ border-radius: 8px;
2948
+ overflow: hidden;
2949
+ background-size: cover;
2950
+ background-position: center;
2951
+ cursor: grab;
2952
+ touch-action: none;
2953
+ }
2954
+ .sc-padReset {
2955
+ position: absolute;
2956
+ top: 3px;
2957
+ right: 3px;
2958
+ display: flex;
2959
+ align-items: center;
2960
+ justify-content: center;
2961
+ width: 18px;
2962
+ height: 18px;
2963
+ padding: 0;
2964
+ border: 0;
2965
+ border-radius: 6px;
2966
+ background: color-mix(in srgb, #000 45%, transparent);
2967
+ color: #fff;
2968
+ font-size: 11px;
2969
+ line-height: 1;
2970
+ cursor: pointer;
2971
+ }
2972
+ .sc-padReset:hover {
2973
+ background: color-mix(in srgb, #000 65%, transparent);
2974
+ }
2975
+ .sc-pad:focus-visible {
2976
+ outline: 2px solid var(--dsw-focus-ring-color, var(--sc-calendar-accent));
2977
+ outline-offset: -2px;
2978
+ }
2979
+ /* The pad previews the photo with the framing in effect, so dragging shows
2980
+ the result directly. */
2981
+ .sc-padLayer {
2982
+ position: absolute;
2983
+ inset: 0;
2984
+ background-size: cover;
2985
+ background-position: center;
2986
+ pointer-events: none;
2987
+ }
2988
+ .sc-btn {
2989
+ flex: none;
2990
+ min-height: 26px;
2991
+ padding: 3px 10px;
2992
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.12)));
2993
+ border-radius: 7px;
2994
+ background: transparent;
2995
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
2996
+ font: inherit;
2997
+ font-size: 12px;
2998
+ cursor: pointer;
2999
+ }
3000
+ .sc-btn:hover:enabled {
3001
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 8%, transparent);
3002
+ }
3003
+ .sc-btn:active:enabled {
3004
+ background: color-mix(in srgb, var(--sc-calendar-accent) 22%, transparent);
3005
+ border-color: color-mix(in srgb, var(--sc-calendar-accent) 55%, transparent);
3006
+ }
3007
+ .sc-btn[aria-pressed='true'] {
3008
+ border-color: color-mix(in srgb, var(--sc-calendar-accent) 55%, transparent);
3009
+ background: color-mix(in srgb, var(--sc-calendar-accent) 14%, transparent);
3010
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
3011
+ }
3012
+ .sc-btn:disabled {
3013
+ opacity: 0.45;
3014
+ cursor: default;
3015
+ }
3016
+ .sc-btnWide {
3017
+ width: 100%;
3018
+ }
3019
+ .sc-iconBtn {
3020
+ flex: none;
3021
+ display: inline-flex;
3022
+ align-items: center;
3023
+ justify-content: center;
3024
+ width: 22px;
3025
+ height: 22px;
3026
+ padding: 0;
3027
+ border: 0;
3028
+ border-radius: 6px;
3029
+ background: transparent;
3030
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
3031
+ font: inherit;
3032
+ font-size: 14px;
3033
+ line-height: 1;
3034
+ cursor: pointer;
3035
+ }
3036
+ .sc-iconBtn:hover {
3037
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 9%, transparent);
3038
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
3039
+ }
3040
+ .sc-fontPicker {
3041
+ position: relative;
3042
+ flex: 1 1 auto;
3043
+ min-width: 0;
3044
+ }
3045
+ .sc-fontBtn {
3046
+ display: flex;
3047
+ align-items: center;
3048
+ justify-content: space-between;
3049
+ gap: 6px;
3050
+ width: 100%;
3051
+ height: 26px;
3052
+ padding: 0 8px;
3053
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
3054
+ border-radius: 7px;
3055
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 4%, transparent);
3056
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
3057
+ font: inherit;
3058
+ font-size: 12px;
3059
+ cursor: pointer;
3060
+ }
3061
+ .sc-fontBtnLabel {
3062
+ overflow: hidden;
3063
+ text-overflow: ellipsis;
3064
+ white-space: nowrap;
3065
+ text-align: left;
3066
+ }
3067
+ .sc-fontCaret {
3068
+ flex: none;
3069
+ color: var(--sc-text-dim, var(--dsw-alias-label-tertiary));
3070
+ font-size: 10px;
3071
+ }
3072
+ .sc-fontSearch {
3073
+ position: sticky;
3074
+ top: -4px;
3075
+ z-index: 1;
3076
+ padding: 2px 2px 6px;
3077
+ background: var(--dsw-specific-menu, var(--dsw-alias-bg-overlay, var(--dsw-alias-bg-layer-1)));
3078
+ }
3079
+ .sc-fontSearchInput {
3080
+ width: 100%;
3081
+ box-sizing: border-box;
3082
+ font-family: inherit;
3083
+ }
3084
+ .sc-fontEmpty {
3085
+ padding: 6px 8px;
3086
+ color: var(--sc-text-dim, var(--dsw-alias-label-tertiary));
3087
+ font-size: 12px;
3088
+ }
3089
+ .sc-fontMenu {
3090
+ position: fixed;
3091
+ z-index: 4;
3092
+ overflow-y: auto;
3093
+ padding: 4px;
3094
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
3095
+ border-radius: 8px;
3096
+ background: var(--dsw-specific-menu, var(--dsw-alias-bg-overlay, var(--dsw-alias-bg-layer-1)));
3097
+ box-shadow: var(--dsw-elevation-prominent);
3098
+ }
3099
+ .sc-fontItem {
3100
+ display: block;
3101
+ width: 100%;
3102
+ padding: 4px 8px;
3103
+ border: 0;
3104
+ border-radius: 6px;
3105
+ background: transparent;
3106
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
3107
+ font-size: 13px;
3108
+ text-align: left;
3109
+ white-space: nowrap;
3110
+ overflow: hidden;
3111
+ text-overflow: ellipsis;
3112
+ cursor: pointer;
3113
+ }
3114
+ .sc-fontItem:hover {
3115
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 9%, transparent);
3116
+ }
3117
+ .sc-fontItemAuto {
3118
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
3119
+ }
3120
+ .sc-fontSep {
3121
+ height: 1px;
3122
+ margin: 4px 2px;
3123
+ background: var(--sc-border, var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12)));
3124
+ }
3125
+ .sc-paletteLine {
3126
+ display: flex;
3127
+ align-items: center;
3128
+ gap: 8px;
3129
+ min-width: 0;
3130
+ }
3131
+ .sc-paletteReset {
3132
+ flex: none;
3133
+ width: auto;
3134
+ padding: 0 8px;
3135
+ white-space: nowrap;
3136
+ }
3137
+ .sc-palette {
3138
+ flex: 1 1 auto;
3139
+ /* Never shorter than a swatch: a squeezed row clipped their tops. */
3140
+ min-height: 32px;
3141
+ display: flex;
3142
+ flex-direction: row;
3143
+ align-items: center;
3144
+ gap: 6px;
3145
+ overflow-x: auto;
3146
+ overflow-y: hidden;
3147
+ padding: 4px 2px 6px;
3148
+ box-sizing: border-box;
3149
+ }
3150
+ .sc-paletteRow {
3151
+ flex: none;
3152
+ display: flex;
3153
+ align-items: center;
3154
+ gap: 2px;
3155
+ }
3156
+ .sc-paletteRowPicked .sc-swatch {
3157
+ box-shadow: 0 0 0 2px var(--sc-calendar-accent);
3158
+ }
3159
+ /* Paired controls: two columns keep the editor short. */
3160
+ .sc-triple {
3161
+ display: grid;
3162
+ grid-template-columns: repeat(3, minmax(0, 1fr));
3163
+ gap: 6px;
3164
+ }
3165
+ .sc-triple2 {
3166
+ grid-template-columns: repeat(2, minmax(0, 1fr));
3167
+ }
3168
+ .sc-tripleCell {
3169
+ display: flex;
3170
+ flex-direction: column;
3171
+ align-items: center;
3172
+ gap: 4px;
3173
+ min-width: 0;
3174
+ }
3175
+ .sc-tripleRow {
3176
+ display: flex;
3177
+ align-items: center;
3178
+ gap: 4px;
3179
+ min-width: 0;
3180
+ }
3181
+ .sc-tripleLabel {
3182
+ max-width: 100%;
3183
+ padding: 0;
3184
+ border: 0;
3185
+ background: transparent;
3186
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
3187
+ font: inherit;
3188
+ font-size: 11px;
3189
+ white-space: nowrap;
3190
+ overflow: hidden;
3191
+ text-overflow: ellipsis;
3192
+ cursor: pointer;
3193
+ }
3194
+ .sc-tripleLabel {
3195
+ cursor: default;
3196
+ }
3197
+ .sc-tripleLabelGradient:hover {
3198
+ filter: brightness(1.12) saturate(1.1);
3199
+ }
3200
+ .sc-grid2 {
3201
+ display: grid;
3202
+ grid-template-columns: repeat(2, minmax(0, 1fr));
3203
+ gap: 8px;
3204
+ }
3205
+ .sc-cell2 {
3206
+ display: flex;
3207
+ flex-direction: column;
3208
+ gap: 3px;
3209
+ min-width: 0;
3210
+ }
3211
+ .sc-cell2Span {
3212
+ grid-column: 1 / -1;
3213
+ }
3214
+ .sc-cell2Label {
3215
+ overflow: hidden;
3216
+ text-overflow: ellipsis;
3217
+ white-space: nowrap;
3218
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
3219
+ font-size: 11px;
3220
+ }
3221
+ .sc-cell2Row {
3222
+ display: flex;
3223
+ align-items: center;
3224
+ gap: 4px;
3225
+ }
3226
+ /* Exactly the same box as the colour button it sits beside. */
3227
+ .sc-btnTiny {
3228
+ display: inline-flex;
3229
+ align-items: center;
3230
+ justify-content: center;
3231
+ width: 34px;
3232
+ height: 24px;
3233
+ padding: 0;
3234
+ box-sizing: border-box;
3235
+ font-size: 11px;
3236
+ border-radius: 7px;
3237
+ }
3238
+ .sc-swatchSmall {
3239
+ width: 34px;
3240
+ height: 24px;
3241
+ }
3242
+ .sc-paletteRow .sc-iconBtn {
3243
+ width: 16px;
3244
+ height: 22px;
3245
+ font-size: 12px;
3246
+ }
3247
+ .sc-panelRow {
3248
+ display: flex;
3249
+ flex-wrap: wrap;
3250
+ align-items: center;
3251
+ gap: 6px;
3252
+ }
3253
+ .sc-select {
3254
+ width: 100%;
3255
+ height: 26px;
3256
+ padding: 0 6px;
3257
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.12)));
3258
+ border-radius: 7px;
3259
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 4%, transparent);
3260
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
3261
+ font: inherit;
3262
+ font-size: 12px;
3263
+ }
3264
+ /* The editor must not paint the platform's focus ring: clicking a field or
3265
+ a button used to leave a dark outline behind. Keyboard focus gets a soft
3266
+ accent ring instead, and mouse focus shows nothing extra. */
3267
+ .sc-side button:focus,
3268
+ .sc-side select:focus,
3269
+ .sc-side input:focus {
3270
+ outline: none;
3271
+ }
3272
+ .sc-side button:focus-visible,
3273
+ .sc-side select:focus-visible,
3274
+ .sc-side input:focus-visible {
3275
+ outline: none;
3276
+ box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--sc-calendar-accent) 55%, transparent);
3277
+ }
1233
3278
  .sc-launchLabel {
1234
3279
  overflow: hidden;
1235
3280
  text-overflow: ellipsis;
@@ -1238,7 +3283,7 @@ window.__ModuleLoader__.load({
1238
3283
  .sc-launch:hover {
1239
3284
  border-color: color-mix(in srgb, var(--sc-calendar-accent) 68%, transparent);
1240
3285
  background: color-mix(in srgb, var(--sc-calendar-accent) 10%, transparent);
1241
- color: var(--dsw-alias-label-primary);
3286
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1242
3287
  }
1243
3288
  .sc-launchRail:hover {
1244
3289
  border-color: color-mix(in srgb, var(--sc-calendar-accent) 55%, transparent);
@@ -1246,25 +3291,25 @@ window.__ModuleLoader__.load({
1246
3291
  }
1247
3292
  }
1248
3293
 
1249
- .sc-card {
3294
+ /* One surface for the calendar and its look editor: the shell owns the
3295
+ position, the background and the outer radius, so the two columns read
3296
+ as a single shape — a cell dividing, not two cards side by side. */
3297
+ .sc-shell {
1250
3298
  position: fixed;
1251
3299
  /* Vertical centring without a transform: auto margins split the free
1252
3300
  space, which keeps the backdrop blur sampling correctly. */
1253
3301
  top: 0;
1254
3302
  bottom: 0;
1255
- height: min(720px, calc(100vh - 24px));
1256
- max-height: calc(100vh - 24px);
1257
3303
  margin-top: auto;
1258
3304
  margin-bottom: auto;
1259
3305
  z-index: 1;
1260
3306
  display: flex;
1261
- flex-direction: column;
1262
- width: ${CARD_WIDTH}px;
1263
- max-width: calc(100vw - 24px);
3307
+ flex-direction: row;
3308
+ align-items: stretch;
3309
+ max-height: calc(100vh - 24px);
1264
3310
  box-sizing: border-box;
1265
- border: 0;
1266
3311
  border-radius: 16px;
1267
- /* No backdrop-filter here: it promotes the card to its own composited
3312
+ /* No backdrop-filter here: it promotes the surface to its own composited
1268
3313
  layer, and a quick hover's background change can then miss the frame
1269
3314
  that paints before the pointer leaves — the control looks inert when
1270
3315
  the pointer moves fast. The menu token is already 94% opaque, so the
@@ -1274,26 +3319,96 @@ window.__ModuleLoader__.load({
1274
3319
  box-shadow: var(--dsw-elevation-prominent);
1275
3320
  --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);
1276
3321
  --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);
1277
- color: var(--dsw-alias-label-primary);
3322
+ --sc-calendar-accent: #4D6BFE;
3323
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1278
3324
  font-size: 13px;
1279
- line-height: 1.5;
3325
+ line-height: normal;
3326
+ overflow: hidden;
3327
+ }
3328
+ /* A local photo sits above the surface at the chosen opacity and spans the
3329
+ whole shape, so it continues across the seam between the columns. */
3330
+ /* Each column carries the photo so it is centred on that column — the
3331
+ calendar first of all — instead of on the fused shape. */
3332
+ .sc-card[data-bg='image']::before,
3333
+ .sc-side[data-bg='image']::before {
3334
+ content: '';
3335
+ position: absolute;
3336
+ inset: 0;
3337
+ /* Above the surface, behind every label and control: without this the
3338
+ positioned layer painted over the in-flow content. */
3339
+ z-index: -1;
3340
+ background-image: var(--sc-bg-image, none);
3341
+ background-size: cover;
3342
+ background-position: var(--sc-bg-x, 50%) var(--sc-bg-y, 50%);
3343
+ /* Zoom scales the whole layer; the pan then moves the extra overflow. */
3344
+ transform: translate(var(--sc-bg-tx, 0%), var(--sc-bg-ty, 0%)) scale(var(--sc-bg-zoom, 1));
3345
+ opacity: var(--sc-bg-alpha, 0.6);
3346
+ pointer-events: none;
3347
+ }
3348
+ .sc-card {
3349
+ position: relative;
3350
+ z-index: 0;
3351
+ flex: 1 1 auto;
3352
+ min-width: 0;
3353
+ height: 100%;
3354
+ display: flex;
3355
+ flex-direction: column;
3356
+ box-sizing: border-box;
3357
+ background: transparent;
1280
3358
  overflow: hidden;
1281
3359
  outline: none;
1282
3360
  }
1283
3361
  /* The month is a heading; the four controls below split the row evenly,
1284
3362
  so there is no dead stretch between them to miss. */
1285
- .sc-title {
3363
+ .sc-titleRow {
1286
3364
  flex: none;
1287
- padding: 8px 10px 2px;
3365
+ display: flex;
3366
+ align-items: center;
3367
+ gap: 6px;
3368
+ padding: 6px 8px 2px;
3369
+ }
3370
+ .sc-titleSpacer {
3371
+ flex: none;
3372
+ width: 24px;
3373
+ }
3374
+ .sc-title {
3375
+ flex: 1 1 auto;
3376
+ min-width: 0;
1288
3377
  text-align: center;
1289
3378
  font-size: 14px;
1290
3379
  font-weight: 600;
1291
- line-height: 1.5;
1292
- color: var(--dsw-alias-label-primary);
3380
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1293
3381
  overflow: hidden;
1294
3382
  text-overflow: ellipsis;
1295
3383
  white-space: nowrap;
1296
3384
  }
3385
+ .sc-gearBtn {
3386
+ flex: 0 0 30px;
3387
+ display: inline-flex;
3388
+ align-items: center;
3389
+ justify-content: center;
3390
+ height: auto;
3391
+ min-height: 26px;
3392
+ padding: 0;
3393
+ border: 0;
3394
+ border-radius: 6px;
3395
+ background: transparent;
3396
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
3397
+ cursor: pointer;
3398
+ }
3399
+ .sc-gearBtn:hover,
3400
+ .sc-gearBtn.sc-hot {
3401
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 9%, transparent);
3402
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
3403
+ }
3404
+ .sc-gearBtn[aria-expanded='true'] {
3405
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 12%, transparent);
3406
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
3407
+ }
3408
+ .sc-gearBtn:focus-visible {
3409
+ outline: 2px solid var(--dsw-focus-ring-color, var(--sc-calendar-accent));
3410
+ outline-offset: -2px;
3411
+ }
1297
3412
  /* The month row is dressed exactly like the rule switch below it: one
1298
3413
  outlined track holding two-pixel-apart segments. */
1299
3414
  .sc-head {
@@ -1305,9 +3420,9 @@ window.__ModuleLoader__.load({
1305
3420
  padding: 2px;
1306
3421
  min-height: 30px;
1307
3422
  box-sizing: border-box;
1308
- border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));
3423
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
1309
3424
  border-radius: 8px;
1310
- background: color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);
3425
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 5%, transparent);
1311
3426
  user-select: none;
1312
3427
  }
1313
3428
  .sc-navBtn {
@@ -1321,7 +3436,7 @@ window.__ModuleLoader__.load({
1321
3436
  border: 0;
1322
3437
  border-radius: 6px;
1323
3438
  background: transparent;
1324
- color: var(--dsw-alias-label-secondary);
3439
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
1325
3440
  cursor: pointer;
1326
3441
  }
1327
3442
  .sc-navBtn:focus-visible,
@@ -1335,14 +3450,14 @@ window.__ModuleLoader__.load({
1335
3450
  @media (hover: hover) {
1336
3451
  .sc-navBtn:hover,
1337
3452
  .sc-today:hover {
1338
- background: color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent);
1339
- color: var(--dsw-alias-label-primary);
3453
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 9%, transparent);
3454
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1340
3455
  }
1341
3456
  /* Both segments react to the pointer: the resting one lifts, the
1342
3457
  pressed one deepens, so a click never reads as "nothing happened". */
1343
3458
  .sc-seg:not([aria-pressed='true']):hover {
1344
3459
  background: var(--dsw-alias-interactive-bg-hover);
1345
- color: var(--dsw-alias-label-primary);
3460
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1346
3461
  }
1347
3462
  .sc-seg[aria-pressed='true']:hover {
1348
3463
  background: color-mix(in srgb, var(--sc-calendar-accent) 22%, transparent);
@@ -1361,11 +3476,11 @@ window.__ModuleLoader__.load({
1361
3476
  guaranteed repaint, so the controls answer on every entry. */
1362
3477
  .sc-navBtn.sc-hot {
1363
3478
  background: var(--dsw-alias-interactive-bg-hover);
1364
- color: var(--dsw-alias-label-primary);
3479
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1365
3480
  }
1366
3481
  .sc-today.sc-hot {
1367
3482
  background: var(--dsw-alias-interactive-bg-hover);
1368
- color: var(--dsw-alias-label-primary);
3483
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1369
3484
  }
1370
3485
  /* The grouping switch gets its own full-width row: two big segments,
1371
3486
  impossible to miss with the pointer. */
@@ -1376,9 +3491,9 @@ window.__ModuleLoader__.load({
1376
3491
  margin: 0 10px 6px;
1377
3492
  padding: 2px;
1378
3493
  box-sizing: border-box;
1379
- border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));
3494
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
1380
3495
  border-radius: 8px;
1381
- background: color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);
3496
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 5%, transparent);
1382
3497
  }
1383
3498
  .sc-seg {
1384
3499
  flex: 1 1 0;
@@ -1391,15 +3506,15 @@ window.__ModuleLoader__.load({
1391
3506
  border: 0;
1392
3507
  border-radius: 6px;
1393
3508
  background: transparent;
1394
- color: var(--dsw-alias-label-secondary);
3509
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
1395
3510
  font: inherit;
1396
3511
  font-size: 12px;
1397
- line-height: 1;
3512
+ line-height: normal;
1398
3513
  cursor: pointer;
1399
3514
  }
1400
3515
  .sc-seg[aria-pressed='true'] {
1401
3516
  background: color-mix(in srgb, var(--sc-calendar-accent) 16%, transparent);
1402
- color: var(--dsw-alias-label-primary);
3517
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1403
3518
  font-weight: 600;
1404
3519
  }
1405
3520
  .sc-seg:active {
@@ -1411,12 +3526,12 @@ window.__ModuleLoader__.load({
1411
3526
  }
1412
3527
  .sc-navBtn.sc-hot,
1413
3528
  .sc-today.sc-hot {
1414
- background: color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent);
1415
- color: var(--dsw-alias-label-primary);
3529
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 9%, transparent);
3530
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1416
3531
  }
1417
3532
  .sc-seg.sc-hot {
1418
- background: color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent);
1419
- color: var(--dsw-alias-label-primary);
3533
+ background: color-mix(in srgb, var(--sc-text-strong, var(--dsw-alias-label-primary)) 9%, transparent);
3534
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1420
3535
  }
1421
3536
  .sc-seg[aria-pressed='true'].sc-hot {
1422
3537
  background: color-mix(in srgb, var(--sc-calendar-accent) 22%, transparent);
@@ -1432,10 +3547,10 @@ window.__ModuleLoader__.load({
1432
3547
  border: 0;
1433
3548
  border-radius: 6px;
1434
3549
  background: transparent;
1435
- color: var(--dsw-alias-label-secondary);
3550
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
1436
3551
  font: inherit;
1437
3552
  font-size: 12px;
1438
- line-height: 1;
3553
+ line-height: normal;
1439
3554
  cursor: pointer;
1440
3555
  }
1441
3556
  .sc-weekRow {
@@ -1451,9 +3566,8 @@ window.__ModuleLoader__.load({
1451
3566
  align-items: center;
1452
3567
  justify-content: center;
1453
3568
  height: 24px;
1454
- color: var(--dsw-alias-label-tertiary);
3569
+ color: var(--sc-text-dim, var(--dsw-alias-label-tertiary));
1455
3570
  font-size: 12px;
1456
- line-height: 1.6;
1457
3571
  }
1458
3572
  .sc-grid {
1459
3573
  flex: none;
@@ -1467,19 +3581,20 @@ window.__ModuleLoader__.load({
1467
3581
  flex-direction: column;
1468
3582
  align-items: center;
1469
3583
  justify-content: center;
1470
- gap: 2px;
3584
+ gap: 5px;
1471
3585
  height: 38px;
1472
3586
  padding: 0;
1473
3587
  box-sizing: border-box;
1474
- border: 1.5px solid var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12));
1475
- border-color: color-mix(in srgb, var(--dsw-alias-label-secondary) 15%, transparent);
3588
+ border: 1.5px solid var(--sc-border, var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12)));
3589
+ /* The neutral frame is a faint ink by default; a custom border colour
3590
+ overrides it like every other outline. */
3591
+ border-color: var(--sc-border, color-mix(in srgb, var(--dsw-alias-label-secondary) 15%, transparent));
1476
3592
  border-radius: 10px;
1477
3593
  background: transparent;
1478
- color: var(--dsw-alias-label-primary);
3594
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1479
3595
  font: inherit;
1480
3596
  font-size: 14px;
1481
3597
  font-variant-numeric: tabular-nums;
1482
- line-height: 1.6;
1483
3598
  cursor: pointer;
1484
3599
  outline: none;
1485
3600
  }
@@ -1503,7 +3618,7 @@ window.__ModuleLoader__.load({
1503
3618
  inset: -1.5px;
1504
3619
  border-radius: inherit;
1505
3620
  padding: 1.5px;
1506
- background: var(--sc-ring, var(--dsw-alias-border-l3));
3621
+ background: var(--sc-ring, var(--sc-border, var(--dsw-alias-border-l3)));
1507
3622
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
1508
3623
  -webkit-mask-composite: xor;
1509
3624
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
@@ -1517,7 +3632,7 @@ window.__ModuleLoader__.load({
1517
3632
  light one — because the brand blue on the card was hard to read. The
1518
3633
  underline carries the "today" mark instead. */
1519
3634
  .sc-cellToday .sc-dayNum {
1520
- color: var(--dsw-alias-label-primary);
3635
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1521
3636
  font-weight: 700;
1522
3637
  text-decoration: underline;
1523
3638
  text-decoration-color: color-mix(in srgb, var(--sc-calendar-accent) 70%, transparent);
@@ -1526,14 +3641,13 @@ window.__ModuleLoader__.load({
1526
3641
  }
1527
3642
  .sc-cellSelected {
1528
3643
  background: color-mix(in srgb, var(--sc-calendar-accent) 16%, transparent);
1529
- color: var(--dsw-alias-label-primary);
3644
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1530
3645
  font-weight: 600;
1531
3646
  }
1532
3647
  .sc-cellSelected:not(.sc-cellFilled) {
1533
3648
  border-color: var(--sc-calendar-accent);
1534
3649
  }
1535
3650
  .sc-dayNum {
1536
- line-height: 18px;
1537
3651
  }
1538
3652
  /* One dot per Workspace present that day; a row holds five, then wraps. */
1539
3653
  .sc-dots {
@@ -1550,13 +3664,13 @@ window.__ModuleLoader__.load({
1550
3664
  width: 5px;
1551
3665
  height: 5px;
1552
3666
  border-radius: 50%;
1553
- background: var(--sc-dot, var(--dsw-alias-label-tertiary));
3667
+ background: var(--sc-dot, var(--sc-text-dim, var(--dsw-alias-label-tertiary)));
1554
3668
  }
1555
3669
  .sc-divider {
1556
3670
  flex: none;
1557
3671
  height: 1px;
1558
3672
  margin: 0 10px;
1559
- background: var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.06));
3673
+ background: var(--sc-border, var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.06)));
1560
3674
  }
1561
3675
  .sc-dayHead {
1562
3676
  flex: none;
@@ -1576,7 +3690,7 @@ window.__ModuleLoader__.load({
1576
3690
  .sc-dayCount {
1577
3691
  flex: none;
1578
3692
  font-size: 11.5px;
1579
- color: var(--dsw-alias-label-secondary);
3693
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
1580
3694
  }
1581
3695
  .sc-list {
1582
3696
  flex: 1 1 auto;
@@ -1611,8 +3725,10 @@ window.__ModuleLoader__.load({
1611
3725
  padding: 6px 7px 3px;
1612
3726
  border: 0;
1613
3727
  border-radius: 6px;
1614
- background: var(--dsw-specific-menu, var(--dsw-alias-bg-layer-1));
1615
- color: var(--dsw-alias-label-secondary);
3728
+ /* Same wash as the session rows, so the group title sits on the list
3729
+ instead of on a solid band. */
3730
+ background: color-mix(in srgb, var(--sc-accent, currentColor) 5%, transparent);
3731
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
1616
3732
  font: inherit;
1617
3733
  font-size: 12px;
1618
3734
  font-weight: 600;
@@ -1620,7 +3736,7 @@ window.__ModuleLoader__.load({
1620
3736
  cursor: pointer;
1621
3737
  }
1622
3738
  .sc-groupHead:hover {
1623
- color: var(--dsw-alias-label-primary);
3739
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1624
3740
  }
1625
3741
  .sc-groupHead:focus-visible {
1626
3742
  outline: 2px solid var(--dsw-focus-ring-color, var(--sc-calendar-accent));
@@ -1629,7 +3745,7 @@ window.__ModuleLoader__.load({
1629
3745
  .sc-groupChevron {
1630
3746
  flex: none;
1631
3747
  display: inline-flex;
1632
- color: var(--dsw-alias-label-tertiary);
3748
+ color: var(--sc-text-dim, var(--dsw-alias-label-tertiary));
1633
3749
  transform: rotate(90deg);
1634
3750
  transition: transform 120ms ease;
1635
3751
  }
@@ -1656,11 +3772,11 @@ window.__ModuleLoader__.load({
1656
3772
  width: 100%;
1657
3773
  padding: 4px 8px;
1658
3774
  box-sizing: border-box;
1659
- border: 1px solid var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12));
3775
+ border: 1px solid var(--sc-border, var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.12)));
1660
3776
  border-color: color-mix(in srgb, var(--sc-accent, currentColor) 42%, transparent);
1661
3777
  border-radius: 9px;
1662
3778
  background: color-mix(in srgb, var(--sc-accent, currentColor) 5%, transparent);
1663
- color: var(--dsw-alias-label-primary);
3779
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1664
3780
  font: inherit;
1665
3781
  font-size: 13.5px;
1666
3782
  text-align: left;
@@ -1676,7 +3792,7 @@ window.__ModuleLoader__.load({
1676
3792
  .sc-rowTime {
1677
3793
  flex: none;
1678
3794
  font-size: 11px;
1679
- color: var(--dsw-alias-label-secondary);
3795
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
1680
3796
  font-variant-numeric: tabular-nums;
1681
3797
  }
1682
3798
  .sc-note {
@@ -1686,23 +3802,23 @@ window.__ModuleLoader__.load({
1686
3802
  margin: auto 0;
1687
3803
  padding: 18px 16px 20px;
1688
3804
  text-align: center;
1689
- color: var(--dsw-alias-label-secondary);
3805
+ color: var(--sc-text, var(--dsw-alias-label-secondary));
1690
3806
  font-size: 12.5px;
1691
3807
  }
1692
3808
  .sc-note strong {
1693
3809
  display: block;
1694
3810
  margin-bottom: 4px;
1695
- color: var(--dsw-alias-label-primary);
3811
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1696
3812
  font-weight: 600;
1697
3813
  }
1698
3814
  .sc-retry {
1699
3815
  margin-top: 10px;
1700
3816
  height: 28px;
1701
3817
  padding: 0 12px;
1702
- border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));
3818
+ border: 0.5px solid var(--sc-border, var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1)));
1703
3819
  border-radius: 8px;
1704
3820
  background: transparent;
1705
- color: var(--dsw-alias-label-primary);
3821
+ color: var(--sc-text-strong, var(--dsw-alias-label-primary));
1706
3822
  font: inherit;
1707
3823
  font-size: 12px;
1708
3824
  cursor: pointer;
@@ -1739,6 +3855,11 @@ window.__ModuleLoader__.load({
1739
3855
  function apply(ctx) {
1740
3856
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'session-calendar: dictionaries')
1741
3857
 
3858
+ // Paint from the local cache immediately, then swap in the durable file
3859
+ // once the Host answers (it survives restarts; the cache cannot).
3860
+ readSettings()
3861
+ void syncSettingsWithHost()
3862
+
1742
3863
  // The sidebar row renders while the card is closed, so the shared
1743
3864
  // stylesheet lives beside both seats and is removed on dispose.
1744
3865
  ctx.effect(() => {