/* 外壳与系统界面 */

.boot {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--sp-3);
  color: var(--text-3);
}
.boot-title { font-size: var(--fs-15); color: var(--text); font-weight: var(--fw-semi); }
.boot-msg   { font-size: var(--fs-13); color: var(--danger); max-width: 280px; text-align: center; }
.boot-hint  { font-size: var(--fs-12); max-width: 280px; text-align: center; line-height: 1.6; }

/* ---- 状态栏 ---- */
.statusbar {
  position: relative; z-index: 1;
  flex: none; height: var(--statusbar-h); padding: 0 var(--sp-4);
  display: flex; align-items: center; justify-content: space-between;
  font-size: var(--fs-12); font-weight: var(--fw-medium);
  color: var(--text);
  /* 会话换了顶栏颜色时跟着换（system/chatlook.js），平时透明 */
  background: var(--look-status-bg, transparent);
}
.sb-icons { display: flex; align-items: center; gap: var(--sp-1); }
.sb-level { font-size: var(--fs-11); color: var(--text-2); }

/* 壁纸用 fixed 而不是 absolute。.root 的高度是加载时量出来的可视高度
   (见 CLAUDE.md 第 1 条),地址栏一收起可视区就比它高,absolute 会跟着
   .root 一起停在半空,底下露出一条底色。fixed 的包含块是视口,永远铺满。
   它纯粹是背景,不参与布局,所以不会像 dvh 那样把界面抽动。 */
.wallpaper {
  position: fixed; inset: 0; z-index: 0;
  /* 同上：图由 --wall 喂进来，声明写在这儿，美化盖得住 */
  background-image: var(--wall, none);
  background-size: cover; background-position: center;
}

.screen { flex: 1; min-height: 0; position: relative; overflow: hidden; z-index: 1; }
.home-layer, .app-layer { position: absolute; inset: 0; }
.app-layer { background: var(--bg); animation: fade-in var(--dur-fast) var(--ease); }
/* 刘海那一条（--top-inset，见 base.css .root）。主界面、没有顶栏的页面整层往下让；
   有顶栏的页面不让，由顶栏自己把高度加上这一条、底色铺上去，字和按钮仍在安全区以下 */
.home-layer, .app-layer { padding-top: var(--top-inset); }
.app-layer:has(> .page > .navbar:first-child) { padding-top: 0; }
.app-layer > .page > .navbar:first-child {
  height: calc(var(--navbar-h) + var(--top-inset));
  padding-top: var(--top-inset);
}

/* ---- 主界面 ---- */
.home { height: 100%; display: flex; flex-direction: column; padding: var(--sp-3) var(--sp-5) 0; }
.home-grid {
  flex: 1; min-height: 0; display: grid;
  gap: var(--grid-gap);
  align-content: start; justify-content: center;
}
.home-grid.is-edit .cell-app .app-tile,
.home-grid.is-edit .cell-widget { animation: jiggle .5s ease-in-out infinite; }
/* 整理模式下小组件内部自己的点击（比如点开会话）不能抢走格子的点击，
   否则一点就跳进 app，没法移除或移动 */
.home-grid.is-edit .cell-widget .wg { pointer-events: none; }

.cell { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.cell-app {
  align-items: center; justify-content: flex-start; gap: 5px; cursor: pointer;
  overflow: hidden;
}
.cell-app:active .app-tile { transform: scale(.93); }
.app-tile {
  position: relative; height: calc(var(--cell, 76px) * var(--tile-ratio));
  width: auto; aspect-ratio: 1;
  max-width: 100%; flex: none;
  border-radius: 24%; background: var(--tile-bg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--tile-shadow);
  transition: transform var(--dur-fast) var(--ease);
}
/* 关掉名称时不要改图标大小。Dock 的高度和胶囊的 min-height 都是拿
   --tile-ratio 算的，这里单独把 .app-tile 调高，胶囊不会跟着长，
   图标就顶出胶囊了。名称只是藏起来，格子里剩下的空间靠居中吃掉。 */
:root[data-icon-label="off"] .cell-app { justify-content: center; }
:root[data-icon-shadow="off"] .app-tile { box-shadow: none; }
/* 只能写 background-color。写 background 简写会把下面 .has-image 的
   background-size 一起重置成 auto，自定义图标就按原尺寸画、只露出一角。 */
:root[data-wallpaper="on"] .app-tile {
  background-color: var(--capsule-bg); border: 1px solid var(--capsule-border);
  box-shadow: none;
}
:root[data-wallpaper="on"][data-glass="on"] .app-tile { backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur)); }
/* 变量没设上时退回当前文字色。少了这个兜底，`--icon-color` 一旦缺失，
   整格图标就是「位置在、画不出来」，而那正是最难查的一种 */
.app-tile svg { color: var(--icon-color, currentColor); width: 52%; height: 52%; }
/* 图标整张放进去，永远不裁。存的时候已经补成方图带透明边，
   这里再用 contain 兜一层：格子万一不是正方也不会切掉。 */
.app-tile.has-image {
  /* 图走变量，不走内联样式。挂了契约钩子的元素上写内联样式，作者写什么
     都盖不住它（见 ARCHITECTURE 4.136）。变量喂进来，这条声明在这儿 */
  background-image: var(--tile-img, none);
  background-size: contain; background-position: center; background-repeat: no-repeat;
}
.app-name {
  font-size: var(--fs-11); color: var(--text-2); max-width: 100%;
  text-align: center; line-height: 1.2;
}
/* 壁纸下用白字加投影，否则深色壁纸上读不清 */
:root[data-wallpaper="on"] .app-name {
  color: var(--on-scrim); text-shadow: 0 1px 3px rgba(0, 0, 0, .55);
}
:root[data-wallpaper="on"] .page-dots .dot { background: rgba(255, 255, 255, .45); }
:root[data-wallpaper="on"] .page-dots .dot.is-active { background: var(--on-scrim); }
:root[data-wallpaper="on"] .statusbar { color: var(--on-scrim); }

/* 整屏接管的页面自己声明状态栏该用哪种字色（ui/page.js 的 statusBarStyle）。
   线下、锁屏这些页面的底色和 app 主题未必一致，不声明的话浅底上会是浅字。 */
/* 线下整屏接管时，外壳那条状态栏底下也要是线下的底色，否则深色主题上方
   会留一条白边（见 ARCHITECTURE 4.107）。底色由 system/stage.js 写上来。 */
:root[data-stage="on"] .root,
:root[data-stage="on"] .page { background: var(--sg-chrome, var(--bg)); }

:root[data-statusbar="light"] .statusbar { color: var(--on-scrim); }
:root[data-statusbar="light"] .sb-level { color: var(--on-scrim); opacity: .72; }
:root[data-statusbar="dark"] .statusbar { color: var(--on-paper); }
:root[data-statusbar="dark"] .sb-level { color: var(--on-paper); opacity: .68; }
:root[data-wallpaper="on"] .hi-bar { background: var(--on-scrim); opacity: .7; }
:root[data-icon-label="off"] .app-name,
:root[data-icon-label="off"] .dock-name { display: none; }
.tile-badge {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px;
  padding: 0 5px; border-radius: var(--r-full); background: var(--accent);
  color: var(--on-accent); font-size: var(--fs-11); line-height: 17px;
  text-align: center; box-shadow: 0 0 0 2px var(--bg);
}

/* 文件夹：一格里塞四个缩小的图标。做成 2x2 而不是叠成一摞，
   因为一眼要看出里面装的是哪几个。多于四个的看不见，点开才有。 */
.folder-tile {
  position: relative; height: calc(var(--cell, 76px) * var(--tile-ratio));
  width: auto; aspect-ratio: 1; max-width: 100%; flex: none;
  border-radius: 24%; background: var(--tile-bg);
  box-shadow: var(--tile-shadow);
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  gap: 6%; padding: 11%;
  transition: transform var(--dur-fast) var(--ease);
}
:root[data-wallpaper="on"] .folder-tile {
  background: var(--capsule-bg); border: 1px solid var(--capsule-border);
  box-shadow: none;
}
:root[data-wallpaper="on"][data-glass="on"] .folder-tile { backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur)); }
:root[data-icon-shadow="off"] .folder-tile { box-shadow: none; }
.cell-app:active .folder-tile { transform: scale(.93); }
.home-grid.is-edit .folder-tile { animation: jiggle .5s ease-in-out infinite; }
/* 里面那几个小图标不再自己画底和影子，否则一格里四层阴影糊成一团 */
.folder-dot { display: block; min-width: 0; min-height: 0; }
.folder-dot .app-tile {
  height: 100%; width: 100%; aspect-ratio: auto;
  border-radius: 28%; box-shadow: none; background: var(--bg);
}
.folder-dot .app-tile svg { width: 58%; height: 58%; }

/* 打开的文件夹 */
.folder-open {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4); padding: var(--sp-2) var(--sp-1) var(--sp-4);
}
.folder-open .folder-app {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: none; border: 0; padding: 0; cursor: pointer; min-width: 0;
}
.folder-open .app-tile { height: auto; width: 100%; }
.folder-open .app-name { color: var(--text-2); text-shadow: none; }

.cell-slot {
  align-items: center; justify-content: center;
  border: 1px dashed var(--border-2); border-radius: var(--r-md);
  color: var(--text-3); cursor: pointer;
}
.cell-slot svg { color: var(--text-3); }

.cell-widget {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); overflow: hidden; cursor: pointer;
}
/* 去掉卡片底，组件直接落在壁纸上。圆角留着，裁剪仍然按格子来 */
.cell-widget.is-bare { background: none; box-shadow: none; }
.cell.is-picked { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-md); }

/* 挂件。白底卡片，留白给足，不显得局促 */
.cell-widget {
  background: var(--wg-solid); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); overflow: hidden; cursor: pointer;
}
:root[data-wallpaper="on"] .cell-widget {
  box-shadow: none; border: 1px solid var(--capsule-border);
}
:root[data-wallpaper="on"][data-glass="on"] .cell-widget { backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur)); }
.wg {
  height: 100%; padding: var(--sp-4); display: flex; flex-direction: column;
  gap: var(--sp-2); min-width: 0; color: var(--text);
}
.wg-head {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-12); color: var(--text-3);
}
.wg-head svg { color: var(--text-3); }
.wg-rows { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: auto; margin-bottom: auto; }
.wg-row { min-width: 0; }
.wg-row-title { font-size: var(--fs-14); font-weight: var(--fw-medium); }
.wg-row-sub { font-size: var(--fs-12); color: var(--text-3); margin-top: 2px; }
.wg-moment-text {
  font-size: var(--fs-13); color: var(--text-2); line-height: 1.55; margin: 4px 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.wg-empty { font-size: var(--fs-12); color: var(--text-3); margin: auto; }
.wg-stat-num { font-size: var(--fs-56); font-weight: var(--fw-bold); line-height: 1; margin-top: auto; letter-spacing: -2px; }
.wg-clock { justify-content: center; }
.wg-clock-time { font-size: var(--fs-56); font-weight: 200; line-height: 1; letter-spacing: -2px; }

/* 播放器横条 */
.wg-player {
  flex-direction: row; align-items: center; gap: var(--sp-5);
  padding: var(--sp-5); position: relative;
}
.wg-player.is-right { flex-direction: row-reverse; }
.wg-player.is-serif .pl-line { font-family: var(--font-serif); }
.pl-cover {
  flex: none; height: 100%; aspect-ratio: 1;
  border-radius: var(--r-md); background: var(--capsule-bg);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.pl-cover svg { color: var(--text-3); }
.pl-text {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  justify-content: center; gap: 2px;
}
.wg-player.is-right .pl-text { text-align: right; }
.pl-mark { position: absolute; top: var(--sp-4); right: var(--sp-4); color: var(--text-3); }
.wg-player.is-right .pl-mark { right: auto; left: var(--sp-4); }

.pl-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
.pl-sm { font-size: var(--fs-12); color: var(--text-3); }
.pl-md { font-size: var(--fs-15); color: var(--text-2); }
.pl-lg { font-size: var(--fs-20); font-weight: var(--fw-medium); }
.pl-xl { font-size: var(--fs-28); font-weight: var(--fw-bold); letter-spacing: -.5px; }

/* 文字块与图片块 */
.wg-note { justify-content: center; gap: var(--sp-1); }
.wg-note.is-serif .pl-line { font-family: var(--font-serif); }
.wg-note .pl-line { white-space: normal; }
.wg-photo {
  padding: 0; background-size: cover; background-position: center;
  justify-content: flex-end; position: relative;
}
.wg-photo-empty {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; color: var(--text-3); background: var(--surface-2);
}
.wg-photo-empty svg { color: var(--text-3); }
.wg-photo-cap {
  position: relative; padding: var(--sp-3); font-size: var(--fs-13);
  color: var(--on-scrim); background: linear-gradient(transparent, rgba(0, 0, 0, .55));
}
.wg-edit-cover { display: flex; gap: var(--sp-2); }

.page-dots { flex: none; display: flex; justify-content: center; gap: 6px; padding: var(--sp-3) 0; }
.dot { width: 6px; height: 6px; border-radius: var(--r-full); background: var(--border-2); }
.dot.is-active { background: var(--text-2); }

.edit-bar {
  position: absolute; left: var(--sp-3); right: var(--sp-3); bottom: var(--sp-3);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  background: var(--surface); border-radius: var(--r-full); box-shadow: var(--shadow-2);
}
.edit-hint { font-size: var(--fs-12); color: var(--text-2); }
.edit-acts { display: flex; align-items: center; gap: var(--sp-1); }

/* ---- Dock ---- */
.dock {
  position: relative; z-index: var(--z-dock);
  flex: none;
  /* 图标(cell*ratio) + 胶囊上下内边距(sp-2 x2) + Dock 上下内边距(sp-2 x2) */
  height: calc(var(--cell, 76px) * var(--tile-ratio) + var(--sp-8) + var(--safe-bottom));
  min-height: calc(var(--dock-h) + var(--safe-bottom));
  padding: var(--sp-2) var(--sp-5) calc(var(--sp-2) + var(--safe-bottom));
  background: transparent; z-index: var(--z-dock);
}
.dock-capsule.is-edit .app-tile { animation: jiggle .5s ease-in-out infinite; }
.dock-slot.is-picked .app-tile { outline: 2px solid var(--text); outline-offset: 3px; }
.dock-empty.is-edit { border-style: solid; opacity: .7; }
/* 空位只在编辑时画出来。平时画一圈虚线框，看着像少装了什么 */
.dock-empty:not(.is-edit) { visibility: hidden; }

.dock-capsule {
  height: 100%; display: grid; grid-template-columns: repeat(4, 1fr);
  align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  min-height: calc(var(--cell, 76px) * var(--tile-ratio) + var(--sp-4));
  background: var(--capsule-bg); border-radius: var(--r-xl);
  border: 1px solid var(--capsule-border);
}
:root[data-glass="on"] .dock-capsule { backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur)); }
.dock-slot {
  display: flex; align-items: center; justify-content: center;
  min-width: 0; height: 100%;
}

.dock-empty {
  border: 1px dashed var(--border-2); border-radius: 24%; opacity: .4;
  height: calc(var(--cell, 76px) * var(--tile-ratio));
  width: auto; aspect-ratio: 1; align-self: center;
}

/* ---- 左上角那个悬浮返回键。和底部横条二选一，见 shell/NavBack.js ---- */
.navback {
  position: absolute; z-index: var(--z-call);
  top: var(--top-inset); left: var(--sp-1);
  width: 48px; height: var(--navbar-h);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
/* 页面把顶栏换成了深色或浅色（聊天背景里的「顶栏字色」）：悬浮键跟着换，
   不然深色顶栏上压着一个深色箭头 */
:root[data-statusbar="light"] .navback { color: var(--on-scrim); }
:root[data-statusbar="dark"] .navback { color: var(--on-paper); }
/* 开了悬浮键就没有底部横条，页面自己那个返回箭头也让位 —— 同一个位置
   不放两个返回。用 visibility 不用 display：导航栏是三列网格，
   左边那一格塌掉标题就不居中了 */
:root[data-nav="back"] .home-indicator { display: none; }
:root[data-nav="back"] .navbar .nav-left { visibility: hidden; }
/* 放映厅全屏：悬浮返回键就是「退出全屏」（WatchPage 把 onBack 设成 leaveFull）。
   画面是黑的，给它一个半透明的深色圆底才看得见；页面自己那个关闭键让位 ——
   画面横过来时它正好转到左上角，被悬浮键盖住 */
:root[data-nav="back"]:has(.wt.is-full) .navback {
  top: calc(var(--top-inset) + var(--sp-3)); left: var(--sp-3); width: 34px; height: 34px;
  border-radius: var(--r-full); background: rgba(0, 0, 0, .45); color: var(--on-scrim);
}
:root[data-nav="back"] .wt.is-full .wt-exit { display: none; }

.home-indicator {
  position: relative; z-index: 1;
  flex: none; height: 22px; display: flex; align-items: center; justify-content: center;
  background: transparent; cursor: pointer;
}
.hi-bar { width: 108px; height: 4px; border-radius: var(--r-full); background: var(--text-3); opacity: .5; }

/* ---- 通知横幅。从顶上掉下来，往上一推收起 ---- */
.banner-host {
  position: absolute; top: 0; left: 0; right: 0; z-index: var(--z-banner);
  /* 绝对定位是贴着 .root 的 padding box 算的，量不到 .root 自己的 padding-top，
     所以刘海这段要在这儿再让一次，否则横幅会掉到状态栏底下。 */
  padding: calc(var(--safe-top) + var(--sp-2)) var(--sp-3) 0;
  pointer-events: none;
}
.banner {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--capsule-bg); border: 1px solid var(--capsule-border);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  animation: banner-in var(--dur) var(--ease-out);
}
:root[data-glass="on"] .banner { backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur)); }
.banner.is-leaving { animation: banner-out .2s var(--ease) forwards; }
@keyframes banner-in  { from { transform: translateY(-130%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes banner-out { to { transform: translateY(-130%); opacity: 0; } }

.banner-icon {
  flex: none; width: 34px; height: 34px; border-radius: var(--r-md);
  background: var(--tile-bg); color: var(--icon-color);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.banner-text { flex: 1; min-width: 0; }
.banner-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  font-size: var(--fs-11); color: var(--text-3);
}
.banner-app { min-width: 0; }
.banner-time { flex: none; }
.banner-title { font-size: var(--fs-14); font-weight: var(--fw-semi); margin-top: 1px; }
.banner-body {
  font-size: var(--fs-13); color: var(--text-2); line-height: 1.4; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* 没铺壁纸时胶囊底色几乎透明，横幅会看不清，这里补成实底 */
:root[data-wallpaper="off"] .banner { background: var(--surface); border-color: var(--border); }

/* ---- 锁屏 ---- */
.lock {
  height: 100%; display: flex; flex-direction: column;
  /* 「上滑解锁」那一行在最底下，不让开安全区就正好压在 Home Indicator 上 */
  padding: calc(var(--sp-6) + var(--top-inset)) var(--sp-4) calc(var(--sp-6) + var(--safe-bottom));
  background: linear-gradient(170deg, var(--surface-2), var(--bg));
}
.lock.has-wallpaper { background: none; }
.lock.has-wallpaper .lock-time,
.lock.has-wallpaper .lock-date,
.lock.has-wallpaper .lock-unlock {
  color: var(--on-scrim); text-shadow: 0 1px 6px rgba(0, 0, 0, .5);
}
.lock-clock { text-align: center; margin-top: var(--sp-8); }
.lock-time { font-size: var(--fs-56); font-weight: 200; letter-spacing: -2px; line-height: 1.05; }
.lock-date { font-size: var(--fs-14); color: var(--text-2); margin-top: var(--sp-1); }
.lock-notifications { flex: 1; min-height: 0; margin-top: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); }
.lock-note {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); background: var(--surface); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); color: var(--text-2); cursor: pointer;
}
.lock-note-body { flex: 1; min-width: 0; }
.lock-note-title { font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text); }
.lock-note-text { font-size: var(--fs-12); color: var(--text-2); margin-top: 1px; }
.lock-note-x { color: var(--text-3); padding: var(--sp-1); }
.lock-unlock {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text-3); font-size: var(--fs-12); padding: var(--sp-4) 0 var(--sp-2);
}

/* ---- 多任务 ---- */
:root[data-glass="on"] .switcher { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.switcher {
  position: absolute; inset: 0; z-index: var(--z-app);
  background: var(--scrim-strong);
  display: flex; flex-direction: column; justify-content: center; gap: var(--sp-4);
  animation: fade-in var(--dur-fast) var(--ease);
}
.switcher-head { text-align: center; color: var(--on-scrim); font-size: var(--fs-13); opacity: .85; }
.switcher-cards { display: flex; gap: var(--sp-3); padding: 0 var(--sp-4); overflow-x: auto; }
.sw-card {
  position: relative; flex: none; width: 116px; height: 168px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
}
.sw-close {
  position: absolute; top: var(--sp-2); right: var(--sp-2); z-index: 1;
  width: 22px; height: 22px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.sw-body {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--sp-3);
}
.sw-body .app-tile { width: 52px; }
.sw-name { font-size: var(--fs-12); color: var(--text-2); }

/* ---- app 加载与崩溃 ---- */
.app-loading { height: 100%; display: flex; align-items: center; justify-content: center; }
.crash {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-6); text-align: center; color: var(--text-3);
}
.crash-title { font-size: var(--fs-15); color: var(--text); font-weight: var(--fw-semi); margin-top: var(--sp-2); }
.crash-msg { font-size: var(--fs-12); color: var(--text-2); max-width: 280px; line-height: 1.6; word-break: break-all; }
.crash-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-4); }

/* Love 日历 */
.wg-love {
  --love-ink: var(--text);
  color: var(--love-ink);
  container-type: size;
  padding: var(--sp-5);
  gap: var(--sp-4);
}
.wg-love.is-serif .love-word,
.wg-love.is-serif .love-month { font-family: var(--font-serif); }

.love-top { display: grid; grid-template-columns: 34% 1fr; gap: var(--sp-4); align-items: center; }
.love-avatar {
  aspect-ratio: 1; border-radius: var(--r-full);
  border: 2px solid currentColor;
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  opacity: .92;
}
.love-avatar:not(.has-image) { opacity: .34; }
.love-right { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-2); }

.love-word {
  font-size: var(--fs-28);
  font-size: clamp(var(--fs-24), 9cqw, var(--fs-56));
  line-height: 1;
}

/* 均衡器。纯装饰，跟着 currentColor 走 */
.love-eq { display: flex; align-items: center; gap: 3px; height: 11cqh; overflow: hidden; }
.love-eq i {
  flex: 1; min-width: 2px; max-width: 3px; height: 40%;
  background: currentColor; border-radius: var(--r-full);
  opacity: .82; transform-origin: center;
  animation: love-eq 1.05s ease-in-out infinite alternate;
}
.love-eq i:nth-child(2n) { animation-delay: -.25s; }
.love-eq i:nth-child(3n) { animation-delay: -.55s; }
.love-eq i:nth-child(4n) { animation-delay: -.8s; }
@keyframes love-eq { from { transform: scaleY(.35); } to { transform: scaleY(1.9); } }
@media (prefers-reduced-motion: reduce) {
  .love-eq i { animation: none; height: 55%; }
}

/* 日历吃掉剩下的高度，天数格子按 1fr 平分，固定六行 */
.love-cal {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  border-top: 1px solid currentColor; padding-top: var(--sp-3);
}
.love-cal { border-top-color: color-mix(in srgb, currentColor 16%, transparent); }
.love-cal-head { display: flex; align-items: baseline; justify-content: space-between; }
.love-month { font-size: var(--fs-17); line-height: 1; }
.love-year { font-size: var(--fs-11); opacity: .45; letter-spacing: .12em; }

.love-week, .love-days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.love-week {
  font-size: var(--fs-11); opacity: .48; letter-spacing: .06em;
  margin: var(--sp-3) 0 var(--sp-2);
}
.love-days { flex: 1; min-height: 0; }
.love-day {
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-13); line-height: 1;
}
.love-day.is-today { color: var(--love-ink); }
.love-day.is-today svg { display: block; }

/* 不是本月的日子淡一档，两周视图会带出下个月的头几天 */
.love-day.is-out { opacity: .3; }

/* 2 格见方的小号。只铺两周，所以留白反而可以比原稿更松 */
.wg-love.is-compact { padding: var(--sp-4); gap: var(--sp-3); }
.wg-love.is-compact .love-top { grid-template-columns: 32% 1fr; gap: var(--sp-3); }
.wg-love.is-compact .love-avatar { border-width: 1.5px; }
.wg-love.is-compact .love-word {
  font-size: var(--fs-20);
  font-size: clamp(var(--fs-17), 15cqw, var(--fs-28));
}
.wg-love.is-compact .love-eq { height: 9cqh; gap: 2px; }
.wg-love.is-compact .love-cal { padding-top: var(--sp-3); }
.wg-love.is-compact .love-month { font-size: var(--fs-13); }
.wg-love.is-compact .love-year { font-size: 9px; letter-spacing: .04em; }
.wg-love.is-compact .love-week { font-size: 9px; margin: 6px 0 4px; letter-spacing: 0; }
.wg-love.is-compact .love-day { font-size: var(--fs-12); }

/* 自定义组件。iframe 是 sandbox 的，见 widgets.js */
.wg-custom { width: 100%; height: 100%; border: 0; display: block; background: transparent; }
.wg-custom-empty {
  align-items: center; justify-content: center; text-align: center;
  gap: var(--sp-2); color: var(--text-3); font-size: var(--fs-12);
}
.wg-custom-empty svg { color: var(--text-3); }
.wg-edit-color { display: flex; align-items: center; gap: var(--sp-3); }
.wg-edit-color input[type="color"] {
  width: 46px; height: 32px; padding: 0; border: 0; background: none;
  border-radius: var(--r-sm); cursor: pointer;
}

/* ---- 健康挂件 ---- */
/* 显示哪几项由用户挑，所以格子数不固定，按内容平铺 */
.wg-hl {
  display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-4);
  margin-top: auto; margin-bottom: auto; min-width: 0;
}
.wg-hl-one { min-width: 0; }
.wg-hl-one b {
  display: block; font-size: var(--fs-22); font-weight: var(--fw-semi);
  line-height: 1.1; letter-spacing: -.5px; font-variant-numeric: tabular-nums;
}
.wg-hl-one span { font-size: var(--fs-11); color: var(--text-3); }
/* 一格高的时候只剩一行数字，标题栏让出去 */
.wg-health.is-flat .wg-hl { gap: var(--sp-3); align-items: baseline; }
.wg-health.is-flat .wg-hl-one b { font-size: var(--fs-18); }

/* ---- 保活中断的那一条 ---- */
/* 压在最上面：它本身就是恢复手段，点不到就没有意义 */
.ka-banner {
  position: fixed; left: var(--sp-4); right: var(--sp-4);
  top: calc(var(--sp-4) + env(safe-area-inset-top));
  z-index: var(--z-banner);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-2);
  color: var(--text-3);
}
.ka-text { flex: 1; min-width: 0; }
.ka-title { font-size: var(--fs-14); font-weight: var(--fw-medium); color: var(--text); }
.ka-sub { font-size: var(--fs-11); color: var(--text-3); margin-top: 1px; }
.ka-act {
  flex: none; padding: var(--sp-2) var(--sp-3);
  border: 0; border-radius: var(--r-sm);
  background: var(--text); color: var(--surface);
  font-size: var(--fs-13); font-weight: var(--fw-medium);
}
.ka-close { flex: none; border: 0; background: none; color: var(--text-3); padding: 2px; }

/* ---- 相册挂件 ---- */
.wg-shots {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 3px; margin-top: auto; margin-bottom: auto; min-width: 0;
}
.wg-shots.is-wide { grid-template-columns: repeat(4, 1fr); }
.wg-shot {
  display: block; aspect-ratio: 1 / 1; border-radius: var(--r-xs);
  background: var(--surface-2); background-size: cover; background-position: center;
}
.wg-album.is-flat .wg-shots { grid-template-columns: repeat(3, 1fr); }

/* 还没填内容的小组件上那一句提示 */
.wg-hint { font-size: var(--fs-12); color: var(--text-3); line-height: 1.5; }

/* ---- 主屏拖动（见 screens/home/drag.js） ---- */
/* 主屏本来就不滚动，格子上把浏览器自己的手势让出来，拖动时 pointermove 才不会被接管 */
.home-grid .cell, .dock-slot { touch-action: none; }
/* 跟手的影子。挂在 body 上，不归网格管，所以尺寸、位置全由 drag.js 写死 */
.drag-ghost {
  position: fixed; z-index: var(--z-toast); margin: 0;
  pointer-events: none; will-change: transform; transition: none;
}
.drag-ghost, .drag-ghost * { animation: none !important; }
.drag-ghost .app-tile, .drag-ghost.cell-widget { box-shadow: var(--shadow-3); }
/* 拿起来的那一格留个淡影在原处，看得出它从哪儿来 */
.cell.is-lifted, .dock-slot.is-lifted { opacity: .25; }
/* 让位预览里，拖着的那一格已经排进了落点：那里空着，其他格子围着它让开 */
.cell.is-away { visibility: hidden; }
/* 松手会落在哪几格 */
.cell-drop {
  pointer-events: none; border-radius: var(--r-md);
  border: 2px dashed var(--text-3); background: var(--surface-2); opacity: .7;
}
.dock-slot.is-over .app-tile, .dock-empty.is-over { outline: 2px solid var(--text); outline-offset: 3px; }

/* ---- ins 风小组件（screens/home/insWidgets.js） ----
   黑白、留白、发丝线、衬线字与小写英文标注。颜色一律来自 tokens */

/* 圆头像；ring 为 new 时外面一圈实线（二十四小时内发过动态），seen 时一圈发丝线 */
.ins-round {
  flex: none; width: var(--round); height: var(--round); border-radius: 50%;
  padding: 2px; display: inline-flex;
}
.ins-round.is-new { box-shadow: 0 0 0 1.5px var(--text); }
.ins-round.is-seen { box-shadow: 0 0 0 1px var(--border-2); }
.ins-round-in {
  width: 100%; height: 100%; border-radius: 50%; background: var(--surface-2) center / cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-13); color: var(--text-3);
}

/* 拍立得 */
.ins-polaroid { padding: var(--sp-3); align-items: center; justify-content: center; }
.ins-paper {
  width: 100%; height: 100%; background: var(--paper); color: var(--on-paper);
  box-shadow: var(--shadow-2); padding: 7% 7% 0; display: flex; flex-direction: column;
  transition: transform var(--dur-slow) var(--ease-out);
}
.ins-polaroid.is-tilt-l .ins-paper { transform: rotate(-2.5deg) scale(.96); }
.ins-polaroid.is-tilt-r .ins-paper { transform: rotate(2.5deg) scale(.96); }
.ins-shot {
  flex: 1; min-height: 0; background: var(--surface-2) center / cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: var(--on-paper-2);
}
.ins-caption {
  flex: none; height: 26%; min-height: 34px; display: flex; flex-direction: column; justify-content: center;
  gap: 1px; font-family: var(--font-serif); font-style: italic; min-width: 0;
}
.ins-caption-t {
  font-size: var(--fs-14); line-height: 1.25; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ins-caption-d { align-self: flex-end; font-size: var(--fs-9); color: var(--on-paper-2); font-style: normal; letter-spacing: .5px; }

/* 胶片：上下两排齿孔用重复渐变画，颜色取 tokens */
.ins-film {
  padding: 0; gap: 0; background: var(--film); color: var(--on-film); position: relative; justify-content: center;
}
.ins-holes {
  flex: none; height: 12px; margin: 0 6px;
  background: repeating-linear-gradient(90deg, transparent 0 6px, var(--on-film-2) 6px 12px, transparent 12px 18px);
  -webkit-mask: linear-gradient(transparent 3px, var(--film) 3px, var(--film) 9px, transparent 9px);
  mask: linear-gradient(transparent 3px, var(--film) 3px, var(--film) 9px, transparent 9px);
  opacity: .8;
}
.ins-frames { flex: 1; min-height: 0; display: flex; gap: 6px; padding: 2px 6px; }
.ins-frame { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ins-frame-img { flex: 1; min-height: 0; background: var(--on-film-2) center / cover no-repeat; }
.ins-frame-img.is-empty { opacity: .25; }
.ins-frame-no { font-family: var(--font-mono); font-size: var(--fs-9); color: var(--on-film-2); letter-spacing: 1px; }
/* 片边上的字压在上排齿孔那一条上，底下垫一块片基色，像印在胶片边上 */
.ins-film-mark {
  position: absolute; right: 14px; top: 0; line-height: 12px; padding: 0 4px; background: var(--film); font-family: var(--font-mono); font-size: var(--fs-9);
  letter-spacing: 2px; color: var(--on-film-2);
}

/* 快拍 */
.ins-stories { flex-direction: row; align-items: center; justify-content: flex-start; padding: var(--sp-2) var(--sp-3); gap: var(--sp-2); overflow: hidden; }
.ins-story {
  flex: none; width: 58px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer;
}
.ins-story-name { max-width: 100%; font-size: var(--fs-11); color: var(--text-2); }

/* 主页卡 */
.ins-profile { gap: var(--sp-1); justify-content: center; }
.ins-profile-top { display: flex; align-items: center; gap: var(--sp-5); margin-bottom: var(--sp-2); }
.ins-profile-stats { flex: 1; display: flex; justify-content: space-around; text-align: center; }
.ins-profile-stats b { display: block; font-size: var(--fs-17); font-weight: var(--fw-semi); }
.ins-profile-stats span { font-size: var(--fs-11); color: var(--text-3); letter-spacing: .3px; }
.ins-profile-name { font-size: var(--fs-14); font-weight: var(--fw-semi); }
.ins-profile-sign { font-size: var(--fs-13); color: var(--text-2); }

/* 九宫格：没有标题、没有圆角，只有两像素的缝 */
.ins-grid { padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px; }
.ins-tile { background: var(--surface-2) center / cover no-repeat; min-width: 0; min-height: 0; }
.ins-tile.is-empty { background: var(--surface-2); }

/* 一句 */
.ins-quote { justify-content: center; gap: var(--sp-1); font-family: var(--font-serif); }
.ins-quote-mark { font-size: var(--fs-40); line-height: .6; height: 18px; color: var(--text-3); }
.ins-quote-text {
  font-size: var(--fs-17); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ins-quote-by { font-size: var(--fs-12); color: var(--text-3); font-style: italic; margin-top: var(--sp-1); }

/* 在一起 */
.ins-days { align-items: center; justify-content: center; gap: 2px; text-align: center; }
.ins-days-faces { display: flex; margin-bottom: var(--sp-1); }
.ins-days-faces .ins-round + .ins-round { margin-left: -8px; }
.ins-days-faces .ins-round-in { box-shadow: 0 0 0 2px var(--surface); }
.ins-days-n { font-family: var(--font-serif); font-size: var(--fs-40); font-weight: 300; line-height: 1.05; letter-spacing: -1px; }
.ins-days-sub { font-size: var(--fs-12); color: var(--text-2); letter-spacing: .3px; }
.ins-days-since { font-size: var(--fs-11); color: var(--text-3); font-family: var(--font-serif); font-style: italic; }

/* 天气 */
.ins-weather { justify-content: center; gap: 2px; }
.ins-weather-city { font-size: var(--fs-12); color: var(--text-2); letter-spacing: .3px; }
.ins-weather-city span { color: var(--text-3); }
.ins-weather-t { font-size: var(--fs-40); font-weight: 200; line-height: 1.1; letter-spacing: -1px; }
.ins-weather-t i { font-style: normal; color: var(--text-3); margin: 0 2px; }
.ins-weather-x { font-size: var(--fs-13); color: var(--text-2); }
.ins-weather-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* 两格高：城市在上、气温居中、天气在下。外面那层拆掉，三行直接排在卡片里 */
.ins-weather:not(.is-flat) .ins-weather-meta { display: contents; }
.ins-weather:not(.is-flat) .ins-weather-city { order: -1; }
.ins-weather:not(.is-flat) .ins-weather-x { order: 1; }
.ins-weather.is-flat { flex-direction: row; align-items: center; gap: var(--sp-3); }
.ins-weather.is-flat .ins-weather-t { flex: none; font-size: var(--fs-24); }
.ins-weather.is-flat .ins-weather-meta { flex: 1; }


/* ---- 登录页 ---- */
.login {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3); padding: 0 var(--sp-6); max-width: 360px; margin: 0 auto; background: var(--bg);
}
.login-icon { width: 76px; height: 76px; border-radius: var(--r-lg); }
.login-title { font-size: var(--fs-24); font-weight: var(--fw-semi); color: var(--text); margin-bottom: var(--sp-3); }
.login-note, .login-err { font-size: var(--fs-13); text-align: center; line-height: 1.6; }
.login-note { color: var(--text-2); }
.login-err { color: var(--danger); }
.login-fields { width: 100%; display: flex; flex-direction: column; gap: var(--sp-2); }
.login-fields input { width: 100%; }
.login .btn { width: 100%; margin-top: var(--sp-2); }
.login-hint { font-size: var(--fs-12); color: var(--text-3); text-align: center; line-height: 1.6; margin-top: var(--sp-2); }
.login-retry { font-size: var(--fs-13); color: var(--text-2); text-decoration: underline; padding: var(--sp-2); }

/* ---- 排查读数（system/diag.js，地址加 ?diag 才有）。放在屏幕中间，不挡上下两条 ---- */
.diag {
  position: fixed; left: var(--sp-2); right: var(--sp-2); top: 40%; z-index: calc(var(--z-banner) + 10);
  margin: 0; padding: var(--sp-2); border-radius: var(--r-md);
  background: var(--scrim-strong); color: var(--on-scrim);
  font: var(--fs-11)/1.5 var(--font-mono); white-space: pre-wrap;
  pointer-events: none;
}

/* ---- 测试版标记（system/channel.js）。贴在左边缘中间，点不到，不挡边缘返回 ---- */
.test-tag {
  position: fixed; left: 0; top: 50%; transform: translateY(-50%);
  z-index: calc(var(--z-banner) + 20);
  writing-mode: vertical-rl; letter-spacing: 2px;
  padding: var(--sp-2) 2px; border-radius: 0 var(--r-xs) var(--r-xs) 0;
  background: var(--danger); color: var(--on-scrim); font-size: var(--fs-11);
  opacity: .85; pointer-events: none;
}
