/* CFMail — 布局与自定义组件样式(颜色全部走主题 token,控件层为 Web Awesome) */
* { box-sizing: border-box; }
html, body { height: 100%; }
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-body: var(--font-ui);
  --font-brand: var(--font-ui);
}
body {
  margin: 0;
  font: 14px/1.5 var(--font-ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* The page itself does not move.
   The shells are viewport-height boxes whose insides scroll, so any give in the page itself is
   slack: rubber-banding at the top reads as pull-to-refresh about to fire, and a pinch zooms a
   layout that was computed for exactly this width. Both off -- panning stays, inside the panes
   that scroll. Long-pressing a row is how a finger opens a menu, so the callout and the text
   selection it fights with are off on rows too; text anyone would quote -- a message body, a
   preview -- is in an iframe or its own pane and keeps its selection.
   页面本身不动。
   外壳是视口高的盒子,滚动发生在它们内部,于是页面自己的任何"松动"都是空行程:
   顶部的橡皮筋看起来像下拉刷新要触发,一次捏合缩放的是恰好为这个宽度算出来的版式。
   两样都关 —— 平移保留,在真正滚动的窗格里面。长按一行是手指打开菜单的方式,
   所以行上的呼出气泡、以及与之打架的文本选择也一并关掉;
   人会想引用的文字 —— 正文、预览 —— 都在 iframe 或自己的窗格里,选择照旧。 */
html, body { overscroll-behavior: none; }
/* Sideways on a notched phone the viewport now runs edge to edge (viewport-fit=cover); these
   keep the in-flow content out of the ears while the background reaches both sides. All zero
   anywhere else. Fixed overlays sit outside this padding and carry their own below.
   开了 viewport-fit=cover 后,带刘海的手机横过来视口直抵两边;这两行让文档流里的内容躲开
   两只耳朵,而背景铺满。其它任何地方这两个值都是零。fixed 浮层不吃这份内边距,各自另带。 */
html { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
/* The top inset is zero everywhere this app is meant to run -- the status bar is opaque and the
   page starts below it. It is honoured anyway, and the full-height shells below subtract it,
   for the one case where it is not zero: iOS, after the native video player is dismissed, may
   hand the page back extending under the status bar and report the overlap here. Then the
   content steps down out of it instead of hiding under the clock.
   顶部内边距在这个应用该跑的每个地方都是零 —— 状态栏不透明,页面从它下面开始。
   但仍然照收,下面那些占满整屏的外壳也照减,只为那一种不为零的情形:iOS 在原生视频播放器
   收起之后,可能把页面交还成伸到状态栏底下的样子,并在这里报出重叠的高度。
   那时内容会退下来让开,而不是藏在时钟下面。 */
:root { --sat: env(safe-area-inset-top, 0px); }
html { padding-top: var(--sat); }
/* That padding moves only what is in the flow. A layer that is position: fixed measures from
   the viewport itself and never sees it -- so every such layer that touches the top edge steps
   down by the same amount on its own, wherever it is declared. Found the hard way: after the
   padding alone, the page's own top bar stepped down and the preview's head stayed under the
   clock.
   那份内边距只挪得动文档流里的东西。position: fixed 的层是从视口本身量起的,根本看不见它 ——
   所以每一个贴着顶边的这种层,都在各自声明的地方往下退同样一段。这是吃过亏才知道的:
   只加了内边距之后,页面自己的顶栏退下来了,预览的头部还压在时钟底下。 */
/* A component that is not yet defined is not drawn: without this an undefined <wa-button> is a
   run of bare text for a frame, before its definition arrives and gives it a shape. The common
   ones are defined before anything is drawn (see index.html); this catches the rest.
   尚未定义的组件不画:不加这条,一个未定义的 <wa-button> 会先以一串光秃秃的文字出现一帧,
   等定义到了才有形状。常用的几种在画任何东西之前就已定义(见 index.html);这条兜住其余的。 */
wa-button:not(:defined), wa-select:not(:defined), wa-dropdown:not(:defined), wa-switch:not(:defined),
wa-checkbox:not(:defined), wa-dialog:not(:defined), wa-spinner:not(:defined), wa-icon:not(:defined) { visibility: hidden; }
@media (hover: none) {
  html { touch-action: pan-x pan-y; }
  .row, .drv-row, .drv-card, .side-item, .drv-nav-item, .list-toolbar, .topbar, .tabs {
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  }
}
/* Web Awesome paints html with its surface color, and body is only one screen tall -- on any
   longer page a strip of that surface showed below where body ended. Paint the canvas ourselves.
   WA 会给 html 涂它的 surface 色,而 body 只有一屏高 -- 更长的页面在 body 之下会露出一条那个颜色。
   画布的颜色自己来定。 */
html { background: var(--bg); }
/* ---------- 滚动条:全站统一 ----------
   之前各面板都是浏览器默认样式(Windows 上带上下箭头、方角槽),这里统一成圆角。
   18px = 系统默认 15px 的 120%;thumb 用透明 border + background-clip:content-box
   往里收 5px,于是看到的是一条 8px 的居中细条,外框仍是一整条圆角槽。
   Firefox 只认 scrollbar-color/width,做不了圆角,退化成同色系的原生滚动条。 */
:root { scrollbar-color: var(--border-2) var(--hover); }
::-webkit-scrollbar { width: 18px; height: 18px; }
::-webkit-scrollbar-track { background: var(--hover); border-radius: 999px; }
::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 999px;
  border: 5px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }
/* 上下两端的箭头按钮去掉 */
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }

/* 界面字体作用于所有原生控件 */
input, textarea, select, button { font-family: var(--font-ui); }
/* 品牌名字体 */
.logo span, .auth-logo span { font-family: var(--font-brand); }
/* 邮件正文字体(纯文本正文;HTML 正文在 iframe 内单独注入) */
.plainbody, .msg-body { font-family: var(--font-body); }
a { color: var(--link); text-decoration: none; }
[hidden] { display: none !important; }
.flex1 { flex: 1; }
.dim { color: var(--text-2); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
/* Every "still working" state in the app, centred on both axes.
   `flex: 1` centres it inside a flex parent that has room (the drive's main column, a message
   body); `min-height` gives it something to centre within when the parent has none; `margin:
   auto` covers the plain-block case. Text-align alone only ever centred it sideways, leaving
   the spinner pinned near the top of whatever it was filling.
   应用里每一处"仍在进行"的状态,两轴居中。
   flex:1 让它在有余量的 flex 父容器里居中(网盘主列、邮件正文);min-height 在父容器没有高度时
   给它一个可居中的范围;margin:auto 兜住普通块级的情形。
   只靠 text-align 永远只能横向居中,加载动画被钉在所填区域的顶部附近。 */
.boot-loading, .loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 40px; text-align: center; color: var(--text-2);
  flex: 1; margin: auto; min-height: 160px;
}
/* The app's first frame belongs to the company, so it fills the viewport / 应用的第一帧属于企业,占满视口 */
.boot-loading { min-height: calc(100vh - var(--sat)); min-height: calc(100dvh - var(--sat)); }
/* Spinner above the word for a list, below the lockup for the boot screen: in both, the moving
   part sits between the reader and what they are waiting for.
   列表里动画在文字之上,启动屏里在品牌组合之下:两处都让"动着的那个"处在
   读者与他所等待之物之间。 */
.loading::before, .boot-loading::after {
  content: ''; width: 34px; height: 34px; border-radius: 50%; flex: none;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: cfspin .8s linear infinite;
}
@keyframes cfspin { to { transform: rotate(360deg); } }

/* Brand lockup: logo and name at one visual weight, the name in the brand face. Lives here
   rather than in a feature stylesheet because the boot screen paints before any of those load.
   品牌组合:logo 与名称视觉分量相当,名称用品牌字体。放在这里而不是某个功能样式表里,
   因为启动屏在那些样式表加载之前就要画出来。 */
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-lockup span { font-family: var(--font-brand); font-size: 32px; line-height: 1.1; color: var(--text); }
.brand-lockup > wa-icon { color: var(--primary); }
.brand-lockup .brand-logo { height: 42px; }
.empty { padding: 64px 24px; text-align: center; color: var(--text-2); font-size: 15px; }

/* ---------- Web Awesome 全局密度/形状调校 ---------- */
:root {
  --wa-border-radius-scale: 1.25;
  --wa-font-family-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  /* 全局取消聚焦高亮 */
  --wa-focus-ring-width: 0;
  --wa-focus-ring-style: none;
  --wa-focus-ring: none;
  --wa-focus-ring-offset: 0;
}
/* 原生元素与 WA 组件内部一并去掉聚焦环/高亮 */
:focus, :focus-visible { outline: none !important; }
input:focus, textarea:focus, select:focus, button:focus,
.searchbar:focus-within input:focus {
  outline: none !important; box-shadow: none !important;
}
wa-button::part(base):focus, wa-button::part(base):focus-visible,
wa-input::part(base):focus-within, wa-select::part(combobox):focus-within,
wa-textarea::part(base):focus-within, wa-checkbox::part(control):focus-visible {
  outline: none !important; box-shadow: none !important;
}
wa-button { font-weight: 500; }
wa-button.icon::part(base) {
  border-radius: 50%;
  width: 40px; height: 40px;
  padding: 0;
  justify-content: center;
}
wa-button.icon.sm::part(base) { width: 32px; height: 32px; }
wa-button.icon wa-icon { font-size: 20px; }
wa-button.icon.sm wa-icon { font-size: 18px; }
wa-button.danger::part(base) { color: var(--wa-color-danger-on-quiet); }
wa-button.starred::part(base) { color: var(--star); }
wa-dialog { --width: 480px; }
wa-dialog::part(dialog) { border-radius: 20px; }
wa-dropdown::part(menu) { border-radius: 14px; min-width: 240px; }
wa-dropdown-item::part(base) { font-size: 14px; }
wa-toast { z-index: 600; }

/* 平铺型输入(撰写窗 Gmail 风格,无边框) */
wa-input.flat::part(base), wa-select.flat::part(combobox), wa-textarea.flat::part(base) {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
}
wa-input.flat, wa-select.flat { flex: 1; }
wa-input.flat::part(input) { padding: 0; font-size: 14px; }
wa-textarea.flat::part(textarea) { padding: 12px 0; font-size: 14px; line-height: 1.65; }

/* ---------- 通用元素 ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--wa-color-neutral-fill-quiet); color: var(--wa-color-neutral-on-quiet);
  border-radius: 8px;
  padding: 2px 8px; font-size: 12px; line-height: 18px; vertical-align: middle;
}
.chip-ok { background: var(--wa-color-success-fill-quiet); color: var(--wa-color-success-on-quiet); }
.chip-warn { background: var(--wa-color-warning-fill-quiet); color: var(--wa-color-warning-on-quiet); }
.chip-err { background: var(--wa-color-danger-fill-quiet); color: var(--wa-color-danger-on-quiet); }
.chip-x { margin-left: 2px; color: inherit; opacity: .6; font-size: 13px; border: none; background: none; cursor: pointer; padding: 0; }
.chip-x:hover { opacity: 1; }

.badge { margin-left: auto; color: var(--text); font-size: 12px; font-weight: 700; }
.side-item.active .badge { color: var(--accent-text); }

/* 字符代码页下拉:文本预览与两个编辑器共用的一枚小仪表。安静地待在工具栏里,
   不与正文抢注意力;带 BOM 的文件把它锁住,悬停提示会说明原因 */
select.enc-sel {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 12px; padding: 3px 6px; max-width: 150px;
  cursor: pointer; flex: none;
}
select.enc-sel:hover { color: var(--text); background: var(--hover); }
select.enc-sel:disabled { opacity: .55; cursor: default; }
select.enc-sel option { background: var(--panel); color: var(--text); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 500; flex: none; user-select: none;
}

/* ---------- 顶栏 ---------- */
.shell { display: flex; flex-direction: column; height: calc(100vh - var(--sat)); height: calc(100dvh - var(--sat)); }
/* 上留白比下多 8px:下方还有"写邮件"按钮自己的 margin,这样两侧看起来才一样宽 */
.topbar { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px; height: 60px; flex: none; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 20px; margin-right: 24px; user-select: none; }
.logo span { font-weight: 400; }
.logo wa-icon { color: var(--primary); font-size: 24px; }
.searchbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent-soft); border-radius: 999px;
  height: 40px; padding: 0 18px; width: min(680px, 46vw);
  color: var(--text-2);
}
.searchbar:focus-within { background: var(--panel); }
.searchbar input { flex: 1; border: none; outline: none; background: transparent; font-size: 15px; color: var(--text); }
.searchbar wa-icon { font-size: 20px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
/* Mail and Drive both appear on both pages; this marks which one you are looking at, so the
   pair reads as a switcher instead of two identical icons.
   邮件与网盘在两边都列出,这里标出你正看着哪一个 —— 否则就是两个一模一样的图标。 */
.topbar-right wa-button.current::part(base) { background: var(--selected); color: var(--primary); }
/* 只限定高度,宽度按原图比例自适应;过宽时封顶,避免挤压顶栏其余部分 */
.brand-logo {
  display: block; width: auto; object-fit: contain; border-radius: 5px;
  max-width: 200px; flex: none;
}
.auth-brand-logo { max-width: 240px; border-radius: 6px; }
/* logo 只在"非原生模式"下翻转明度(保留色相/饱和度):
   在浅色模式上传的 logo → 暗色下反转;在暗色模式上传的 → 浅色下反转 */
.wa-dark .brand-logo[data-logo-mode='light'] { filter: invert(1) hue-rotate(180deg); }
.wa-light .brand-logo[data-logo-mode='dark'] { filter: invert(1) hue-rotate(180deg); }

/* The brand and the mail/drive switcher live in the account menu wherever the bar had to give
   them up -- which is the phone, where 393px cannot hold a name, a search field and a switcher
   at once. Wider than that, the bar shows them itself and these rows stay out of the menu:
   one entry, two possible places, never both.
   品牌与邮箱/网盘切换,在"栏容不下它们"的地方住进账号菜单 —— 也就是手机:393px 装不下
   名字、搜索框和切换器三样。比这宽,栏自己就摆得下,这些行便不进菜单:
   每个入口一个真身,两处可站,绝不同时。 */
/* A grouping wrapper, not a box: its buttons lay out as the bar's own children.
   只是个成组的包装,不是盒子:里面的按钮照旧作为栏自己的子项排布。 */
.nav-cross { display: contents; }

.um-brand {
  display: none; align-items: center; gap: 9px; padding: 12px 14px 10px;
  font-family: var(--font-brand); font-size: 16px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.um-brand wa-icon { color: var(--primary); font-size: 20px; }
@media (max-width: 640px), ((hover: none) and (max-height: 500px)) {
  .topbar .logo { display: none; }
  .topbar-right .nav-cross { display: none; }
  .um-brand { display: flex; }
}
@media (min-width: 641px) {
  #user-dd .um-nav { display: none; }
}

.um-head { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.um-name { font-weight: 500; }
.um-mail { color: var(--text-2); font-size: 12.5px; }
.um-version { color: var(--text-2); font-size: 12px; padding: 10px 14px 6px; border-top: 1px solid var(--border); margin-top: 6px; }

/* ---------- 侧栏 ---------- */
.body { display: flex; flex: 1; min-height: 0; }
.sidebar { width: 256px; flex: none; padding: 0 8px 16px 8px; overflow-y: auto; }
.sidebar.hidden { display: none; }
.compose-btn { margin: 8px 8px 16px 4px; }
.compose-btn::part(base) {
  height: 44px; padding: 0 20px; border-radius: 14px;
  background: var(--selected); color: var(--accent-text);
  border: none; font-size: 14.5px; font-weight: 500;
  transition: box-shadow .15s;
}
.compose-btn::part(base):hover { box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 30%, transparent), 0 4px 8px color-mix(in srgb, var(--text) 15%, transparent); }
.compose-btn wa-icon { font-size: 20px; }
/* Slotted children lay out inline by default, so the icon aligns to the text baseline and sits
   ~1.5px above the label's centre. Centre them as boxes and let the text box hug its glyphs.
   插槽内容默认按行内基线排布,图标贴着文字基线、比文字中线高约 1.5px。
   改成按盒居中,并让文字盒紧贴字形。 */
.compose-btn::part(label) { display: flex; align-items: center; gap: 8px; }
.compose-btn span { line-height: 1; }
.side-group { display: flex; flex-direction: column; }
.side-item {
  display: flex; align-items: center; gap: 14px;
  height: 36px; padding: 0 12px 0 14px; margin-right: 8px;
  border-radius: 0 999px 999px 0; color: var(--text); font-size: 14px;
  overflow: hidden; white-space: nowrap;
}
.side-item:hover { background: var(--hover-2); }
.side-item.active { background: var(--selected); color: var(--accent-text); font-weight: 700; }
.side-item wa-icon { color: var(--text-2); font-size: 20px; flex: none; }
.side-item.active wa-icon { color: var(--accent-text); }
.side-name { overflow: hidden; text-overflow: ellipsis; }
.side-sep { height: 1px; background: var(--border); margin: 12px 16px 8px 8px; }
.side-title { color: var(--text-2); font-size: 12.5px; padding: 6px 16px; }
.side-item.acct { gap: 10px; }

/* ---------- 内容区 ---------- */
.content {
  flex: 1; min-width: 0; background: var(--panel);
  border-radius: 16px;
  /* 上边距使第一封邮件上边缘与侧栏「写邮件」按钮下边缘对齐:
     按钮下边缘 = 上边距 8 + 按钮高 44 = 52;减去工具栏高 40 → 12 */
  margin: 12px 16px 16px 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar.hidden + .content { margin-left: 16px; }
.list-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 12px; flex: none;
}
.list-toolbar wa-button.icon::part(base) { width: 34px; height: 34px; }
/* 多选工具栏 */
.sel-toolbar { background: var(--selected); }
.sel-all-wrap { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin-left: 4px; }
.sel-all-wrap input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.row-check { width: 32px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.row-check input { width: 16px; height: 16px; accent-color: var(--primary); pointer-events: none; }
.rows.sel-mode .row { cursor: default; }
.rows.sel-mode .row .row-actions { display: none !important; }
.row.selected { background: var(--selected-2); }

/* A positioned menu, worn as a sheet.
   Same element, same entries, same close path -- only the geometry changes: pinned across the
   foot of the screen, rows grown to the height of a thumb, a scrim behind it so the list it
   covers reads as waiting rather than broken. The !important pair is deliberate: the callers set
   left and top inline, and this class exists precisely to overrule where they put it.
   一个定点菜单,穿成动作单的样子。同一个元素、同样的条目、同一条关闭路径 —— 变的只有几何:
   钉在屏幕脚下横贯整宽,行高长到一根拇指,身后垫一层纱,好让被它盖住的列表读作"在等",
   而不是"坏了"。那对 !important 是故意的:调用方会内联设置 left 和 top,
   而这个类存在的目的恰恰就是推翻它们把它放的地方。 */
.menu-sheet {
  left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
  width: auto; min-width: 0; max-width: none;
  border-radius: 16px 16px 0 0;
  max-height: 70vh; max-height: 70dvh; overflow-y: auto;
  padding: 10px max(10px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  box-shadow: 0 -8px 32px color-mix(in srgb, #000 32%, transparent);
  animation: sheet-up .16s ease-out;
}
@keyframes sheet-up { from { transform: translateY(28px); opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .menu-sheet { animation: none; } }
.menu-sheet .ctx-item, .menu-sheet .mi { min-height: 46px; font-size: 15px; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 999; background: color-mix(in srgb, #000 30%, transparent); }
/* The sheet stands over its own scrim / 动作单站在自己那层纱之上 */
.ctx-menu.menu-sheet, .drv-menu.menu-sheet { z-index: 1000; }

/* 右键上下文菜单 */
.ctx-menu {
  position: fixed; z-index: 400; min-width: 190px; padding: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 6px 24px color-mix(in srgb, #000 24%, transparent);
}
.ctx-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; border: none; background: none; cursor: pointer;
  border-radius: 8px; color: var(--text); font: inherit; font-size: 13.5px;
  text-align: left; justify-content: flex-start;
}
.ctx-item:hover { background: var(--hover-2); }
.ctx-item > span { flex: 1; text-align: left; }
.ctx-item wa-icon { font-size: 18px; color: var(--text-2); flex: none; width: 18px; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 8px; }
.ctx-title { padding: 6px 12px 4px; color: var(--text-2); font-size: 12px; }
.ctx-item.danger { color: var(--wa-color-danger-on-quiet); }
.ctx-item.danger wa-icon { color: inherit; }
.list-title { font-size: 14px; color: var(--text-2); margin-left: 6px; font-weight: 500; }
.pageinfo { color: var(--text-2); font-size: 12.5px; margin-right: 4px; }
.rows { overflow-y: auto; flex: 1; }

.row {
  display: flex; align-items: center; gap: 4px;
  height: 36px; padding: 0 16px 0 8px;
  border-bottom: 1px solid var(--hover);
  cursor: pointer; position: relative;
  background: var(--tint);
}
.row.unread { background: var(--panel); }
.row:hover { box-shadow: inset 1px 0 0 var(--border-2), inset -1px 0 0 var(--border-2), 0 1px 2px 0 color-mix(in srgb, var(--text) 30%, transparent); z-index: 1; }
.row-star { flex: none; }
.row wa-button.row-star::part(base) { color: var(--text-3); }
.row wa-button.row-star.starred::part(base) { color: var(--star); }
/* margin 36 + 行内 gap 4 = 发件人与主题之间正好 40px */
.row-from { width: 190px; margin-right: 36px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.row.unread .row-from { font-weight: 700; }
.row-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-subj { color: var(--text); }
.row.unread .row-subj { font-weight: 700; }
.row-snip, .row-sep { color: var(--text-3); }
/* Read mail steps back. Unread already leans forward -- bold, panel-white -- but the read rows
   wore the same ink as everything else, so the eye had weight as its only cue. Now read text is
   a shade lighter on every screen, and the two states read at a glance.
   已读的信往后站一步。未读本来就朝前倾 —— 加粗、面板白 —— 可已读的行用的还是和别处相同的墨,
   眼睛只能靠字重分辨。现在已读的文字在每块屏幕上都浅一号,两种状态一眼可辨。 */
.row:not(.unread) .row-from, .row:not(.unread) .row-subj { color: var(--text-2); }
.cnt { color: var(--text-2); font-weight: 400; font-size: 12.5px; }
.row-clip { color: var(--text-2); flex: none; display: inline-flex; font-size: 16px; }
.row-date { flex: none; width: 84px; text-align: right; font-size: 12px; color: var(--text-2); }
.row.unread .row-date { color: var(--text); font-weight: 700; }
.row-actions {
  display: none; position: absolute; right: 8px; top: 0; bottom: 0;
  align-items: center; gap: 2px; background: inherit; padding-left: 8px;
}
.row:hover .row-actions { display: flex; }
.row:hover .row-date { visibility: hidden; }

/* The same actions, for a pointer that cannot hover.
   A finger has no way to ask a row to show its buttons, and no way to right-click it either, so
   both doors are shut at once. Here the strip is always out and holds a single menu button --
   the four actions live inside it, together with everything else the right-click menu offers.
   It stands in the flow rather than over the row, so the date beside it survives.
   Nothing in this block can reach a mouse: the query is false wherever hovering works.
   同样那些动作,给一个不会悬停的指针。
   手指没法要求一行把按钮显示出来,也没法右键它,于是两扇门同时关上。
   在这里那一条始终露在外面,里面是一个菜单按钮 —— 四个动作都在它里头,
   连同右键菜单提供的其余一切。它站在文档流里而不是压在行上,于是旁边的日期得以幸存。
   这一段够不到鼠标:凡是悬停有效的地方,这条查询都为假。 */
.row-actions .row-menu { display: none; }
@media (hover: none) {
  .row-actions { display: flex; position: static; padding-left: 4px; }
  .row-actions .hover-act { display: none; }
  .row-actions .row-menu { display: inline-flex; }
  .row:hover .row-date { visibility: visible; }
  /* No :hover state may do anything on a touch screen. iOS simulates hover on the first tap,
     and when it judges that the hover "revealed content" it swallows the tap instead of
     delivering the click -- a mail row that needs pressing twice. So on touch, hovering a row
     changes nothing at all, and the first tap is the click.
     触摸屏上不许任何 :hover 生效。iOS 会把第一次触碰模拟成悬停,
     一旦它判定悬停"显示了内容",就吞掉这一击、不派发 click —— 于是邮件行要按两次。
     所以在触摸端,悬停一行什么也不改变,第一击就是那一次点击。 */
  .row:hover { box-shadow: none; z-index: auto; }
  .row:hover .row-actions { display: flex; }
}
.draft-red { color: var(--wa-color-danger-on-quiet); }
.disabled-row { opacity: .55; }

/* ---------- 会话视图 ---------- */
.thread { overflow-y: auto; flex: 1; padding: 0 16px 24px; }
.t-subject { font-size: 22px; font-weight: 400; margin: 16px 8px 8px 44px; }
.msgs { display: flex; flex-direction: column; }
.msg { border-bottom: 1px solid var(--hover); padding: 12px 4px; }
.msg:last-child { border-bottom: none; }
.msg-head { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.msg-meta { min-width: 0; flex: 1; }
.msg-line1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-from { font-weight: 700; font-size: 14px; }
.msg-addr { color: var(--text-2); font-size: 12.5px; }
.msg-line2 { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
.msg-right { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--text-2); flex: none; }
.msg-right > wa-icon { font-size: 16px; }
.msg-date { font-size: 12.5px; }
.msg-date .dt-short { display: none; }
.msg-collapsed { color: var(--text-2); margin: 4px 0 0 52px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.msg.open .msg-collapsed { display: none; }
.msg-bodywrap { display: none; margin: 12px 0 0 52px; }
.msg.open .msg-bodywrap { display: block; }
/* 正文画布透明:发件方自己画的面(卡片/色带)原样保留且不反色,
   其余(转发头、纯文字段落)透出主题背景 */
.mailframe { width: 100%; border: none; display: block; min-height: 60px; background: transparent; border-radius: 8px; }
.plainbody { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.65; }
.msg-actions { display: flex; gap: 8px; margin-top: 16px; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
/* 收信侧的附件条:填充块 + 悬停下载箭头,刻意不用描边,免得和「回复/转发」那类按钮撞脸 */
.atts .att-chip {
  border: none; background: var(--hover);
  border-radius: 8px; padding: 6px 8px 6px 10px; gap: 8px;
  max-width: 320px; transition: background .15s;
}
.atts .att-chip:hover { background: var(--selected); color: var(--accent-text); }
.atts .att-chip .att-size { margin-left: 2px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-2); border-radius: 10px; padding: 6px 10px;
  color: var(--text); font-size: 13px; max-width: 280px; background: var(--panel);
}
.att-chip:hover { background: var(--hover); }
.att-chip wa-icon { font-size: 15px; color: var(--text-2); }
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip .att-size { color: var(--text-2); font-size: 12px; flex: none; }
.att-chip.uploading { opacity: .6; }
.att-chip[data-prev] { cursor: pointer; }

/* 附件大窗预览 */
wa-dialog.attprev-dlg { --width: min(1100px, 94vw); }
.attprev { display: flex; flex-direction: column; gap: 12px; }
.attprev-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.attprev-head wa-icon { font-size: 18px; color: var(--text-2); flex: none; }
.attprev-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attprev-size { color: var(--text-2); font-size: 12.5px; flex: none; }
.attprev-body {
  height: min(76vh, 900px); border-radius: 10px; overflow: auto;
  background: var(--hover); display: flex; align-items: center; justify-content: center;
}
/* 图片按原始比例塞进框里,不放大小图 */
.attprev-body img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.attprev-body iframe { width: 100%; height: 100%; border: none; display: block; border-radius: 10px; }
/* 全窗:撑满视口。WA 默认给 dialog 留了 --wa-space-2xl 的边距和圆角,这里一并去掉。
   正文高度 = 视口 - (上下 padding 10x2 + 头部 32 + 间距 12),留几像素余量免得溢出 */
wa-dialog.attprev-dlg.full { --width: 100vw; --spacing: 10px; }
wa-dialog.attprev-dlg.full::part(dialog) { max-width: 100%; max-height: 100%; border-radius: 0; }
wa-dialog.attprev-dlg.full .attprev-body { height: calc(100vh - 72px); height: calc(100dvh - 72px); border-radius: 0; }
wa-dialog.attprev-dlg.full .attprev-body iframe { border-radius: 0; }
/* 附件类型标记:统一的圆角小正方形,认识的放图标,不认识的写扩展名 */
.fileicon {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px; color: #fff; flex: none;
  font-weight: 700; line-height: 1; letter-spacing: .02em;
}
.fileicon wa-icon { color: #fff; }
.att-x { display: inline-flex; color: var(--text-2); border: none; background: none; cursor: pointer; padding: 0; }
.att-x:hover { color: var(--wa-color-danger-on-quiet); }
.att-x wa-icon { font-size: 14px; }

.replybox { margin: 20px 0 0 8px; }
.replybox-inner { display: flex; gap: 12px; }
.reply-main { flex: 1; border: 1px solid var(--border-2); border-radius: 16px; padding: 12px; }
.reply-main textarea {
  width: 100%; border: none; outline: none; resize: vertical; min-height: 60px;
  font: inherit; font-size: 14px; line-height: 1.6; background: transparent; color: var(--text);
}
.reply-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.reply-main.dragover, .compose.dragover .compose-body {
  outline: 2px dashed var(--primary); outline-offset: -6px;
  background: var(--tint); border-radius: 12px;
}
#reply-atts { border-top: 1px solid var(--hover); margin-top: 6px; padding-top: 8px; }

/* ---------- 撰写窗口 ---------- */
.compose {
  position: fixed; right: 60px; bottom: 0; z-index: 200;
  width: min(500px, calc(100vw - 32px));
  background: var(--panel); border-radius: 12px 12px 0 0;
  box-shadow: 0 8px 28px color-mix(in srgb, #000 28%, transparent);
  display: flex; flex-direction: column;
  max-height: min(70vh, 620px);
}
/* 全屏:铺满页面(再点一次还原) */
.compose.maximized {
  inset: 24px; right: 24px; bottom: 24px;
  width: auto; max-height: none; border-radius: 12px;
}
.compose.minimized .compose-body { display: none; }
.compose-head {
  display: flex; align-items: center; gap: 2px;
  background: var(--accent-soft); color: var(--text);
  font-size: 14px; font-weight: 500;
  border-radius: 12px 12px 0 0; padding: 6px 8px 6px 16px; cursor: pointer; user-select: none;
}
.compose.maximized .compose-head { border-radius: 12px 12px 0 0; }
.compose-head wa-button.icon::part(base) { color: var(--text-2); }
.compose-head wa-button.icon::part(base):hover { color: var(--text); }
.compose-head wa-button.icon.sm::part(base) { width: 28px; height: 28px; }
.cp-status { color: var(--text-2); font-size: 12px; font-weight: 400; margin-right: 6px; }
.compose-body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 0 16px 12px; overflow-y: auto; position: relative; }
.cp-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 8px 0; }
.cp-row > label { color: var(--text-2); font-size: 13px; flex: none; width: 44px; }
/* 撰写窗内的输入框:无边框、无 focus 高亮 */
.cp-row input, .compose-body textarea {
  flex: 1; min-width: 0; border: none; outline: none; box-shadow: none;
  background: transparent; color: var(--text);
  font: inherit; font-size: 14px; padding: 0;
}
.cp-row input:focus, .compose-body textarea:focus { border: none; outline: none; box-shadow: none; }
.cp-row input::placeholder, .compose-body textarea::placeholder { color: var(--text-3); }
.compose-body textarea { flex: 1; min-height: 200px; padding: 14px 0; line-height: 1.65; resize: none; }
.cp-atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0; border-top: 1px solid var(--border); }
.compose-foot { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
/* 邮件总大小:只在有附件/内联图时显示,超限转红 */
.cp-size { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cp-size.over { color: var(--wa-color-danger-on-quiet); font-weight: 600; }

/* ---------- 富文本编辑器(Quill snow 主题接到本站变量上) ---------- */
.cp-editwrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cp-toolbar[hidden] { display: none !important; }
.cp-toolbar.ql-toolbar {
  border: none !important; border-bottom: 1px solid var(--border) !important;
  padding: 4px 0 6px; font-family: inherit;
}
.cp-toolbar.ql-toolbar .ql-formats { margin-right: 10px; }
.cp-toolbar.ql-toolbar button { width: 26px; height: 24px; padding: 3px 4px; }
.cp-toolbar.ql-toolbar button:hover .ql-stroke,
.cp-toolbar.ql-toolbar button.ql-active .ql-stroke,
.cp-toolbar.ql-toolbar .ql-picker-label:hover { stroke: var(--primary); color: var(--primary); }
.cp-toolbar.ql-toolbar button:hover .ql-fill,
.cp-toolbar.ql-toolbar button.ql-active .ql-fill { fill: var(--primary); }
.cp-toolbar.ql-toolbar .ql-stroke { stroke: var(--text-2); }
.cp-toolbar.ql-toolbar .ql-fill { fill: var(--text-2); }
.cp-toolbar.ql-toolbar .ql-picker { color: var(--text-2); }
.cp-toolbar.ql-toolbar .ql-picker-options { background: var(--panel-2); border-color: var(--border); }
/* 容器本身不滚动也不裁剪,滚动交给 .ql-editor —— 否则链接气泡会被切掉 */
.cp-editor.ql-container {
  border: none !important; flex: 1; min-height: 180px; overflow: visible;
  display: flex; flex-direction: column;
  font: inherit; font-size: 14px; color: var(--text);
}
.compose.maximized .cp-editor.ql-container { min-height: 240px; }
.cp-editor .ql-editor { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 0; line-height: 1.65; }
.cp-editor .ql-editor.ql-blank::before { color: var(--text-3); font-style: normal; left: 0; right: 0; }
/* 2px 透明边:给悬停/选中态预留位置,加边框时不会引起版面跳动 */
.cp-editor .ql-editor img { max-width: 100%; height: auto; border: 2px solid transparent; }
.cp-editor .ql-editor blockquote { border-left: 2px solid var(--border); padding-left: 12px; margin-left: 0; color: var(--text-2); }
.cp-editor .ql-editor pre { background: var(--hover); border-radius: 6px; }
/* 插入链接的气泡 */
.cp-editor .ql-tooltip {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 6px 12px; z-index: 300;
  box-shadow: 0 4px 18px color-mix(in srgb, #000 22%, transparent);
}
.cp-editor .ql-tooltip::before { color: var(--text-2); font-size: 13px; }
.cp-editor .ql-tooltip input[type=text] {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font: inherit; font-size: 13px; height: 26px; width: 190px; outline: none;
}
.cp-editor .ql-tooltip input[type=text]:focus { border-color: var(--primary); }
.cp-editor .ql-tooltip a { color: var(--link); font-size: 13px; }
.cp-editor .ql-tooltip a.ql-action::after { border-right-color: var(--border); }
.cp-editor .ql-tooltip a.ql-preview { color: var(--link); }

/* 内联图片的缩放条:hover 到图上才出现 */
.cp-editwrap { position: relative; }
.cp-imgbar {
  position: absolute; z-index: 40; display: flex; gap: 2px;
  background: color-mix(in srgb, var(--panel-2) 92%, transparent);
  border: 1px solid var(--border); border-radius: 8px; padding: 2px;
  box-shadow: 0 2px 10px color-mix(in srgb, #000 22%, transparent);
}
.cp-imgbar button {
  border: none; background: none; color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 22px; padding: 0; border-radius: 6px;
}
.cp-imgbar button:hover { background: var(--hover); color: var(--text); }
.cp-imgbar button.on { background: var(--selected); color: var(--accent-text); }
.cp-imgbar button.del:hover { background: var(--wa-color-danger-fill-quiet); color: var(--wa-color-danger-on-quiet); }
.cp-imgbar-sep { width: 1px; align-self: stretch; margin: 2px 3px; background: var(--border); }

/* 回复引用:默认折成一个 ··· ,点开看,也可以整块丢掉 */
.cp-quote { border-top: 1px solid var(--border); padding: 6px 0; }
.cp-quote-bar { display: flex; align-items: center; gap: 8px; }
.cp-quote-toggle {
  border: 1px solid var(--border); background: var(--hover); color: var(--text-2);
  border-radius: 6px; padding: 0 8px; height: 20px; line-height: 16px; cursor: pointer; font-size: 13px;
}
.cp-quote-toggle:hover { background: var(--selected); }
.cp-quote-label { color: var(--text-3); font-size: 12px; }
.cp-quote-x { border: none; background: none; color: var(--text-3); cursor: pointer; display: flex; padding: 2px; }
.cp-quote-x:hover { color: var(--text); }
.cp-quote-body { max-height: 220px; overflow-y: auto; margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--border); }
.cp-quote-attr { color: var(--text-2); font-size: 12.5px; white-space: pre-wrap; }
.cp-quote-text { color: var(--text-2); font-size: 12.5px; white-space: pre-wrap; margin: 4px 0 0; font-family: inherit; }

/* ---------- 远程图片拦截提示 ---------- */
.imgblock {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; margin-bottom: 8px;
}
.imgblock-txt { color: var(--text-2); font-size: 12.5px; }

/* ---------- 收件人自动补全 ---------- */
.ac-drop {
  position: absolute; z-index: 260; left: 52px; right: 16px;
  background: var(--panel-2); border-radius: 12px;
  box-shadow: 0 4px 18px color-mix(in srgb, #000 22%, transparent);
  overflow: hidden; max-height: 300px; overflow-y: auto;
  border: 1px solid var(--border);
}
.ac-item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; }
.ac-item.sel, .ac-item:hover { background: var(--selected); }
.ac-main { min-width: 0; flex: 1; display: flex; gap: 8px; align-items: baseline; }
.ac-name { font-weight: 500; white-space: nowrap; }
.ac-addr { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 通讯录 ---------- */
.contacts-page { overflow-y: auto; flex: 1; padding: 8px 16px 32px; }
.contact-group { margin-bottom: 12px; }
.contact-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; cursor: pointer; }
.contact-row:hover { background: var(--hover); }
.contact-main { min-width: 0; flex: 1; }
.contact-name { font-weight: 500; }
.contact-addr { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
/* 安全性三档下拉。颜色只在两端出现:可信是绿的,隐患是红的,未知不着色 ——
   一整列彩色等于没有颜色,而未知本来就是"还没人说过",不该抢眼。
   The colour appears only at the two ends. A whole column of colour is no colour at all, and
   unknown means "nobody has said", which is not a thing to shout about. */
.ct-trust { flex: none; width: 104px; }
.ct-trust::part(combobox) { border-color: var(--border); }
.ct-trust.t-trusted::part(combobox) {
  color: var(--wa-color-success-on-quiet); background: var(--wa-color-success-fill-quiet);
  border-color: color-mix(in srgb, var(--wa-color-success-fill-loud) 35%, transparent);
}
.ct-trust.t-risk::part(combobox) {
  color: var(--wa-color-danger-on-quiet); background: var(--wa-color-danger-fill-quiet);
  border-color: color-mix(in srgb, var(--wa-color-danger-fill-loud) 35%, transparent);
}

/* 发件人被标为隐患时,正文上方的提示条 */
.risk-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--wa-color-danger-fill-quiet); color: var(--wa-color-danger-on-quiet);
  border: 1px solid color-mix(in srgb, var(--wa-color-danger-fill-loud) 35%, transparent);
  border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; font-size: 12.5px;
}
.risk-bar wa-icon { flex: none; }

/* 自取邮箱名:输入框 + 固定的 @域名 后缀 */
.name-pick {
  display: flex; align-items: center; gap: 2px;
  border: 1px solid var(--border-2); border-radius: 10px; padding: 0 10px;
  background: var(--panel); min-height: 38px;
}
.name-pick input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 14px; padding: 8px 0; }
.name-suffix { color: var(--text-2); font-size: 14px; white-space: nowrap; flex: none; }
.name-hint { font-size: 12.5px; min-height: 18px; padding: 2px 2px 0; color: var(--text-3); }
.name-hint.ok { color: var(--wa-color-success-on-quiet); }
.name-hint.bad { color: var(--wa-color-danger-on-quiet); }

/* 导入进度条 */
.imp-bar { height: 8px; border-radius: 999px; background: var(--hover); overflow: hidden; margin: 4px 0 8px; }
.imp-bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .2s linear; }
.imp-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.imp-status .imp-eta { font-variant-numeric: tabular-nums; }
/* 导入/导出跑完后的一行结果:跟在按钮右边,不另起一行 */
.run-summary { margin-left: 12px; font-weight: 600; color: var(--text); }
.run-summary:empty { display: none; }
.imp-steps { margin: 10px 0 0; padding-left: 22px; color: var(--text-2); font-size: 13px; line-height: 1.9; }
.imp-steps li { margin: 2px 0; }
.imp-cmd { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.imp-cmd code {
  flex: 1; min-width: 0; overflow-x: auto; white-space: pre;
  padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--hover); color: var(--text); font-size: 12.5px;
  font-family: var(--font-code);
}

/* ---------- 登录/邀请 ---------- */
.auth-wrap { min-height: calc(100vh - var(--sat)); min-height: calc(100dvh - var(--sat)); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 24px;
  width: min(420px, 100%); padding: 40px 40px 32px;
}
.auth-logo { display: flex; align-items: center; gap: 10px; font-size: 24px; color: var(--text-2); margin-bottom: 18px; }
.auth-logo wa-icon { color: var(--primary); font-size: 34px; }
.auth-card h2 { margin: 0 0 6px; font-weight: 500; font-size: 22px; }
.auth-sub { color: var(--text-2); margin: 0 0 12px; font-size: 13.5px; }
.auth-sub b { color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.auth-err { color: var(--wa-color-danger-on-quiet); font-size: 13px; min-height: 18px; }
.auth-foot { color: var(--text-2); font-size: 12.5px; margin-top: 18px; }
.invite-boxes { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.invite-url {
  background: var(--hover); border-radius: 8px; padding: 12px; font-size: 13px;
  word-break: break-all; font-family: ui-monospace, Consolas, monospace; margin: 8px 0;
  user-select: all;
}

/* ---------- 独立页面(设置/管理) ---------- */
.page { min-height: calc(100vh - var(--sat)); min-height: calc(100dvh - var(--sat)); display: flex; flex-direction: column; }
.page-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
/* The title neither shrinks nor wraps. It sits beside a strip that asks for far more width
   than there is, and a flex item that may shrink will: the Japanese title was squeezed from
   140px to 79px and broke over three lines -- CJK wraps between any two characters, so there
   is no long word to stop it -- which made the header taller than the page it heads.
   标题既不收缩也不折行。它旁边是一条要得比现有宽度多得多的页签条，
   而一个允许收缩的 flex 项就会被收缩：日文标题被从 140px 挤到 79px，
   断成三行 —— CJK 在任意两字之间都能折，没有一个长单词拦得住它 ——
   于是头部比它所领的那一页还高。 */
.page-head h1 { font-size: 20px; font-weight: 500; margin: 0; flex: none; white-space: nowrap; }
.tabs {
  display: flex; gap: 4px; margin-left: 24px;
  flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
/* Thirteen tabs are wider than any screen this runs on, a landscape iPad included, so the strip
   scrolls as a strip at every width rather than wrapping into rows or pushing the page along
   with it -- a row of tabs that moves under the thumb is a familiar thing; two rows of them is
   a different navigation, and a page that slides sideways is neither.
   Two things make that work and both are easy to lose. The tabs neither shrink nor wrap, so the
   longest name in any language stays on one line. And the strip is allowed to be narrower than
   what it holds: without min-width: 0 it is a flex item whose floor is everything inside it, so
   the header grows past the window and the whole page scrolls sideways -- navigation and body
   together, which is the one arrangement nobody asked for.
   十三个页签比这套东西会跑的任何屏幕都宽，横放的 iPad 也在内，
   所以这条在任何宽度下都作为一条横向滚动，而不是折行、也不是把整页一起推走
   —— 一排能在拇指下移动的页签是件熟悉的东西；两排页签是另一种导航，
   而一整页往旁边滑，两样都不是。
   让它成立的有两点，而且两点都容易丢。页签既不收缩也不折行，
   于是任何语言里最长的那个名字都留在一行。以及这条允许比它装的东西窄：
   没有 min-width: 0，它就是一个以“里面所有东西”为下限的 flex 项，
   头部因此撑出窗口，整页跟着横向滑动 —— 导航连着主体一起滑，
   而那正是谁都没有要过的那种摆法。 */
@media (max-width: 900px) {
  .tabs { margin-left: 8px; }
}
.tab { flex: none; white-space: nowrap; padding: 8px 16px; border-radius: 999px; color: var(--text-2); font-size: 14px; }
.tab:hover { background: var(--hover); }
.tab.active { background: var(--selected); color: var(--accent-text); font-weight: 500; }
/* 后台/设置页统一:控件基准高度 34px(原生控件与 WA 组件共用这个令牌) */
.page { --wa-form-control-height: 34px; }
.page-body { padding: 20px 24px 60px; max-width: 960px; width: 100%; margin: 0 auto; }
/* 后台是数据密集页,表格列多,放宽;设置页仍保持窄栏 */
.page-body.wide { max-width: 1400px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px 24px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 14px; font-size: 16px; font-weight: 500; }
/* A table wider than the window scrolls inside its own box. Otherwise it pushes the whole page
   sideways and takes the navigation with it -- the members and audit tables did exactly that on
   a landscape iPad, where the rule used to stop at 900px on the grounds that above it these
   tables fit. They do not; a screen being a tablet rather than a phone was never the same thing
   as being wide enough. The care that kept it narrow-only was for menus, which a scroll
   container clips in both directions -- and there are none in any of these tables.
   比窗口宽的表格在自己的盒子里滚动。否则它会把整页往旁边推，连导航一起推走 ——
   成员与审计两张表在横放的 iPad 上正是如此，而这条规则当时停在 900px，
   理由是“断点以上这些表格放得下”。放不下；一块屏幕是平板而不是手机，
   从来就不等于它够宽。当时把它限在窄屏的那份顾虑是为了菜单——
   滚动容器会两个方向一起裁它 —— 而这些表格里一个菜单也没有。 */
.tblwrap { min-width: 0; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--text-2); font-weight: 500; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
/* 单元格内容垂直居中:纯文字与 34px 高的按钮才能对齐到同一中线 */
.table td { padding: 8px 10px; border-bottom: 1px solid var(--hover); vertical-align: middle; }
/* 表格里的按钮压扁一点,避免把行撑高 */
.table td wa-button:not(.icon)::part(base) { height: 28px; min-height: 28px; }
.table td .chip { margin: 1px 0; }
.table tfoot td { color: var(--text-2); border-bottom: none; font-size: 12.5px; }
/* 带标签的行统一:垂直居中、不换行、首个标签固定列宽以便跨行对齐 */
.form-row, .row-flex {
  display: flex; align-items: center; gap: 10px; flex-wrap: nowrap;
}
.form-row { padding: 5px 0; }
.form-row > label, .row-flex > label {
  color: var(--text-2); font-size: 13px; white-space: nowrap; flex: none;
  line-height: 34px;
}
.form-row > label:first-child,
.row-flex > label:first-child { width: 120px; }
/* 同一行里的后续标签(如「角色 …  有效期 …」)只留间距,不占固定列 */
.form-row > label:not(:first-child),
.row-flex > label:not(:first-child) { margin-left: 8px; }
/* WA 的 native.css 会给 <form> 内的控件加上外边距,行内布局下会破坏垂直居中 —— 一律清零 */
.form-row > *, .row-flex > * { margin-block: 0; }
.form-col { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }

/* 邀请记录:授予内容列收窄到原来的 3/5 */
.invites-table th.col-grants, .invites-table td:nth-child(2) { max-width: 200px; white-space: normal; }

/* Members 表格列宽:邮箱账号列收窄(chip 自动换行),最近登录列加宽不换行 */
.members-table th:nth-child(3), .members-table td:nth-child(3) { max-width: 340px; white-space: normal; }
.members-table th:nth-child(6), .members-table td:nth-child(6) { min-width: 150px; white-space: nowrap; }

/* 全局统一按钮文字尺寸(侧栏写邮件按钮除外,它是刻意放大的主操作) */
wa-button:not(.icon):not(.compose-btn)::part(base) { font-size: 13.5px; min-height: 32px; height: auto; padding-block: 4px; }
/* 后台/设置页:按钮与输入框严格同高 34px */
.page wa-button:not(.icon)::part(base) {
  height: 34px; min-height: 34px; padding-block: 0;
}
.page wa-select, .page wa-checkbox { font-size: 13.5px; }

/* 表单里保留的原生 input / select —— 与按钮统一高度和外观 */
.auth-form input, .form-col input,
.row-flex input:not([type=checkbox]),
.page select, #f-profile input, #f-pw input {
  border: 1px solid var(--border-2); border-radius: 8px;
  padding: 0 11px; height: 34px; box-sizing: border-box;
  font: inherit; font-size: 13.5px; outline: none;
  background: var(--panel); color: var(--text);
}
/* 登录/邀请页是纵向表单,输入框略高更舒展 */
.auth-form input { height: 38px; }
/* Web Awesome 的 native.css 给原生 input 设了 width:100%,
   行内表单里会顶满并换行 —— 这里给个合理定宽,保持与前面的文字同一行 */
.row-flex input:not([type=checkbox]) {
  width: 260px; max-width: 100%;
}
.auth-form input::placeholder, input::placeholder { color: var(--text-3); }

/* 主题选择器 */
.theme-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.theme-swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: none;
}
.theme-swatch .dot { width: 24px; height: 24px; border-radius: 50%; border: 1px solid color-mix(in srgb, #000 12%, transparent); }
.theme-swatch:hover { border-color: var(--border-2); }
.theme-swatch.active { border-color: var(--primary); }
.theme-swatch.default-swatch .dot {
  background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 11px;
}

/* ---------- toast 兜底(WA 未就绪时) ---------- */
.toast-fallback {
  position: fixed; left: 24px; bottom: 24px; z-index: 500;
  background: var(--wa-color-neutral-fill-loud); color: var(--wa-color-neutral-on-loud);
  border-radius: 8px; padding: 12px 20px; font-size: 14px;
}

/* ---------- 界面文字不可选中/拖拽 ---------- */
.topbar, .sidebar, .list-toolbar, .page-head, .tabs, .compose-head, .row, .side-title {
  user-select: none; -webkit-user-select: none;
}
.topbar a, .sidebar a, .logo, .brand-logo, .side-item, .tab { -webkit-user-drag: none; }

/* ---------- 字体选择器 ---------- */
.font-dialog { --width: 940px; }
.fp-body { display: grid; grid-template-columns: 1fr 320px; gap: 14px; align-items: start; }
.fp-left, .fp-right { min-width: 0; display: flex; flex-direction: column; }
.fp-right {
  border-left: 1px solid var(--border); padding-left: 14px;
}
.fp-right-head { font-size: 13px; color: var(--text-2); padding: 2px 2px 8px; font-weight: 500; }
.fp-shortlist { border: 1px dashed var(--border-2); border-radius: 10px; padding: 4px; }
.fp-foot { display: flex; align-items: center; gap: 8px; width: 100%; }
.fp-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.fp-head input {
  border: 1px solid var(--border-2); border-radius: 8px; padding: 8px 12px;
  font-size: 13.5px; background: var(--panel); color: var(--text); outline: none;
  width: 100%;
}
.fp-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.fp-cat {
  border: 1px solid var(--border); background: none; color: var(--text-2);
  border-radius: 999px; padding: 4px 12px; font-size: 12.5px; cursor: pointer;
}
.fp-cat:hover { background: var(--hover); }
.fp-cat.active { background: var(--selected); color: var(--accent-text); border-color: transparent; }
.fp-list { max-height: 48vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
/* 两处覆盖缺一不可:
   1) WA 的 native.css 给原生 button 定了固定 height 和 nowrap
   2) .fp-list 是带最大高度的 flex 纵向容器,子项默认会被压缩 → 必须 flex:none */
.fp-item {
  display: flex; flex-direction: column; gap: 5px; align-items: flex-start;
  width: 100%; text-align: left; padding: 10px 34px 10px 12px; border: none; background: none;
  border-radius: 10px; cursor: pointer; color: var(--text);
  height: auto; white-space: normal; overflow: visible;
  flex: none; position: relative;
}
/* 加入预选 / 移出预选 的小按钮 */
.fp-act {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; color: var(--text-2);
  background: var(--panel-2); border: 1px solid var(--border);
}
.fp-item:hover .fp-act { display: inline-flex; }
/* Adding a face to the shortlist is the only thing this button does, and a finger has no way to
   ask for it. Out where it can be pressed, then, on any pointer that cannot hover.
   把一款字体加进预选,是这个按钮唯一做的事,而手指没有办法把它请出来。
   那么就在任何不会悬停的指针上,让它露在外面、按得到。 */
@media (hover: none) {
  .fp-item .fp-act { display: inline-flex; }
}
.fp-act:hover { color: var(--accent-text); border-color: var(--primary); }
.fp-item:hover { background: var(--hover); }
.fp-item.sel { background: var(--selected); }
.fp-name { font-size: 12.5px; line-height: 1.4; color: var(--text-2); }
.fp-item.sel .fp-name { color: var(--accent-text); }
.fp-preview {
  font-size: 19px; line-height: 1.75; color: var(--text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 窄屏:双栏改为上下堆叠 */
@media (max-width: 820px) {
  .font-dialog { --width: calc(100vw - 32px); }
  .fp-body { grid-template-columns: 1fr; }
  .fp-right { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 12px; }
  .fp-shortlist { max-height: 26vh; }
}

/* 字体设置行里的当前值按钮 */
.font-btn::part(base) { width: 260px; justify-content: flex-start; }
/* 行内说明文字过长时省略,避免把控件挤到换行 */
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ellip-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 未匹配来信:弹窗内的正文区 */
wa-dialog.unrouted-dlg { --width: min(900px, 94vw); }
.unrouted-body {
  margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px;
  max-height: min(64vh, 680px); overflow-y: auto;
}
/* 完全沙箱的 iframe 拿不到内容高度,给固定高度并让其内部滚动 */
.unrouted-body .mailframe { border-radius: 6px; height: min(56vh, 600px); min-height: 340px; }
.font-btn .fb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 响应式 ---------- */
/* The way out of an open sidebar on a narrow screen. It sits under the sheet and over
   everything else, and a press anywhere on it closes -- the gesture people already expect from
   every drawer they have ever used. Built by app.js only while it is needed, so nothing on a
   wide screen ever has a transparent sheet lying across it.
   窄屏上,展开的侧栏的那条出路。它压在浮层之下、其余一切之上,按在它任何地方都会关闭 ——
   这是人们从用过的每一个抽屉那里就已经预期的动作。由 app.js 只在需要时创建,
   所以宽屏上任何东西都不会被一层透明的浮层横盖着。 */
.side-backdrop {
  position: fixed; inset: calc(60px + var(--sat)) 0 0 0; z-index: 149;
  background: color-mix(in srgb, #000 26%, transparent);
}
body.impersonating .side-backdrop { inset: calc(94px + var(--sat)) 0 0 0; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: env(safe-area-inset-left, 0px); top: calc(60px + var(--sat)); bottom: 0; z-index: 150;
    background: var(--bg); box-shadow: 4px 0 16px color-mix(in srgb, #000 12%, transparent);
  }
  .sidebar.hidden { display: none; }
  .content { margin-left: 16px; }
  .row-from { width: 120px; margin-right: 16px; }
  .searchbar { width: 40vw; }
  .logo span { display: none; }
}
@media (max-width: 640px), ((hover: none) and (max-height: 500px)) {
  /* The snippet comes back, as a block of its own: the subject keeps its single ellipsized
     line, and under it the first words of the message get two lines at most -- enough to know
     whether to open it, never enough to become the message. The inline dash that introduced it
     beside the subject has nothing to introduce here and goes.
     摘要回来了,自成一块:主题守住它那一行省略,底下正文的开头最多得两行 ——
     足够判断要不要点开,永远不够变成正文本身。在主题旁边负责引出它的那个内联破折号,
     在这里没有什么可引,退下。 */
  .row-main { white-space: normal; }
  .row-main .row-subj { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row-sep { display: none; }
  .row-snip {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; font-size: 12.5px; line-height: 1.45;
  }
  /* The compose button leaves the toolbar: the drawer's own big one is the way in.
     写邮件按钮退出工具条:抽屉里那个大的才是入口。 */
  #btn-compose-sm { display: none; }
  /* Five menu entries, each grown 15% -- these are pressed with a thumb, not a cursor.
     The component keeps its padding on the host, so the host is where it is overruled:
     35px of item plus 2.5px each side is the 40 that 15% comes to.
     五个菜单项,各加高 15% —— 按它们的是拇指,不是光标。
     这个组件把内边距放在宿主上,那就在宿主上推翻它:35px 的项上下各加 2.5px,正是 15% 换来的 40。 */
  #user-dd wa-dropdown-item { padding-block: 10.5px; }
  .searchbar { width: 100%; }
  .compose { right: 0; }
  .t-subject { margin-left: 8px; }
  .msg-collapsed, .msg-bodywrap { margin-left: 0; }

  /* Two lines, because one will not do.
     Sender, date and the label cell all have fixed widths, and on a phone they take the width
     between them and leave the subject about forty pixels -- the one field that says what the
     message is. So the subject drops to a line of its own and gets the whole of it, and the row
     grows by the height of a line rather than losing its point.
     两行,因为一行不够。
     发件人、日期、标签位都是定宽,在手机上它们把宽度瓜分完,给主题剩下约四十像素 ——
     而主题恰恰是那个说出"这封信是什么"的字段。所以主题落到自己一行上、占满它,
     行高多出一行的高度,而不是失去它存在的意义。 */
  .row { flex-wrap: wrap; height: auto; min-height: 54px; padding: 7px 12px 7px 8px; row-gap: 1px; }
  /* Shrinkable to nothing: basis 0, not auto. With basis auto a long sender name sets the
     line's minimum width, the first line overflows, and wrap hands the date the second line --
     the one place a date on a mail row must never be. The name ellipsizes instead.
     可以缩到没有:basis 是 0,不是 auto。basis 为 auto 时,一个长发件人名就定下了这一行的
     最小宽度,第一行装不下,wrap 就把日期递到第二行去 —— 而那正是邮件行上的日期
     唯一不可以在的地方。名字改用省略号。 */
  .row-from { width: auto; flex: 1 1 0; min-width: 0; margin-right: 8px; font-weight: 500; }
  .row-date { flex: none; margin-left: auto; }
  .row-main { order: 10; flex: 1 0 100%; }
  /* The strip stands at the end of the first line, beside the date, rather than under it. */
  /* 那一条站在第一行末尾、日期旁边,而不是落到日期下面。 */
  .row-actions { order: 5; flex: none; }
  /* The label cell keeps a seat, not a bench: one mark's width, clipped past that. On this
     screen the seat exists so rows line up, and the second and third label were always
     readable only in the reading pane anyway.
     标签位留一个座,不留一条凳:一个记号的宽度,再多就裁。在这块屏幕上这个座位的意义是
     让行与行对齐,而第二、第三个标签本来也只有在阅读区才读得清。 */
  /* One selector deeper than the base rule, which sits LATER in this file and would win a tie.
     比基础规则深一层 —— 它在本文件更靠后,平手时是它赢。 */
  .row .row-labels { width: 18px; gap: 0; overflow: hidden; }

  /* The pane is the page. The rounded card the list and the conversation sit inside earns its
     keep beside a sidebar, where it separates panel from ground; here the sidebar is a drawer,
     the ground never shows, and every pixel the card's margins hold is taken from 393.
     窗格就是页面。列表和会话坐在里面的那张圆角卡片,在侧栏旁边是值得的 ——
     它把面板与底色分开;而在这里,侧栏是抽屉,底色根本露不出来,
     卡片的边距攥着的每一个像素,都是从 393 里拿走的。 */
  .content, .sidebar.hidden + .content { margin: 0; border-radius: 0; }
  .thread { padding: 0 10px 24px; }

  /* The console was laid out for a metre of desk.
     Four fixes make it phone-shaped without redesigning a thing. The title refuses to stack
     one character per line -- CJK breaks anywhere, so 管理后台 four rows tall was a column,
     not a heading -- and the tab strip takes the next line whole. Settings rows are allowed
     to wrap, so a label and its field stack instead of running off the right edge, and no
     control may be wider than the screen whatever width it was born with. Table cells hold
     one line each: a table too wide for the phone slides inside its box -- that is what the
     box is for -- rather than folding every number into a tower.
     后台是按一米宽的桌面排的。
     四处修正让它装进手机,而不重排任何东西。标题拒绝一行一个字地摞 —— CJK 在任何字间
     都能断行,于是「管理后台」摞成四行,那是一根柱子,不是一个标题 —— 页签条整条另起一行。
     设置行允许折行,标签和它的控件改为上下排,而不是冲出右缘;任何控件无论生来多宽,
     都不得比屏幕宽。表格单元格各守一行:一张比手机宽的表在它的盒子里滑动 ——
     盒子就是为此而在的 —— 而不是把每个数字折成一座塔。 */
  /* The sender's column gets its width back.
     The right-hand block -- a full date down to the minute, the star -- refuses to shrink, and
     on this screen it was taking half the row: the sender wrapped onto three lines and the
     recipients were cut to a sliver. So the date wears its short face (the long one is a tap
     away on the open message), the bare address hides behind the name it duplicates, and the
     name itself keeps to one ellipsized line. Same DOM, two dates drawn, one shown per width.
     发件人那一列把宽度拿回来。
     右边那一块 —— 精确到分的完整日期、星标 —— 是不肯收缩的,在这块屏幕上它占掉了半行:
     发件人折成三行,收件人被削成一条缝。所以日期换上短脸(长的那张,点开的信里一步就到),
     裸地址躲进它所重复的名字后面,名字自己守住一行省略。同一份 DOM,画两个日期,按宽度亮一个。 */
  .msg-date .dt-long { display: none; }
  .msg-date .dt-short { display: inline; }
  .msg-line1 { flex-wrap: nowrap; min-width: 0; }
  .msg-line1 .msg-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .msg-line1 .msg-addr { display: none; }
  .msg-right { gap: 4px; }

  .page-head { flex-wrap: wrap; padding: 10px 12px; row-gap: 2px; }
  .page-head .tabs { flex: 1 0 100%; margin-left: 0; }
  .page-body { padding: 16px 10px 60px; }
  .form-row, .row-flex { flex-wrap: wrap; row-gap: 6px; }
  .form-row wa-input, .form-row wa-select, .row-flex wa-input, .row-flex wa-select,
  .form-row input, .row-flex input { max-width: 100%; min-width: 0; }
  .font-btn::part(base) { width: auto; max-width: calc(100vw - 24px); }
  .tblwrap th, .tblwrap td { white-space: nowrap; }

  /* Writing a message stops being a window and becomes the page.
     A floating window is a way of writing one thing without losing sight of another, and a
     phone has no second thing in view to lose -- what it has instead is a keyboard that takes
     half the screen, against which 448px of window leaves a writing area three lines tall.
     So it fills the screen, and the one thing a window was for is kept: minimised is still a
     bar at the foot, because a draft you have stepped away from must stay somewhere visible.
     写信不再是一扇窗,而成为这一页。
     浮动窗口的意义,是写一样东西时不必失去另一样的视野,而手机上根本没有第二样东西在视野里
     可失 —— 它有的是一个占掉半块屏幕的键盘;在它面前,448px 高的窗口留下的书写区只有三行。
     所以它铺满屏幕;而窗口本来唯一的用处仍旧保留:最小化仍是脚下的一条 ——
     一份被你暂时搁下的草稿,必须还待在看得见的地方。 */
  /* The top bar runs out of room before the phone does.
     Five icons at forty pixels each, a brand and a search field do not fit across 393px, and
     what gives way first is the search -- the one thing on that bar somebody actually types
     into. So the two icons that lead somewhere already reachable from the account menu stand
     down. Nothing is lost: settings and the admin console are entries in that menu, one press
     away, on the same bar.
     顶栏比手机先没地方。
     五个四十像素的图标、一个品牌、一个搜索框,在 393px 上排不开,而最先让位的是搜索 ——
     那条栏上唯一真会有人往里打字的东西。于是那两个"通往账号菜单里已经到得了的地方"的图标退下。
     什么也没丢:设置与管理后台就是那个菜单里的两条,一按即到,还在同一条栏上。 */
  .topbar { padding-left: 8px; padding-right: 8px; gap: 4px; }
  .topbar-right > .nav-extra { display: none; }
  .logo { margin-right: 8px; }
  .searchbar { width: auto; flex: 1 1 90px; min-width: 0; }

  /* left and right rather than a width: a percentage here is resolved against a containing
     block that mobile WebKit measures as the layout viewport, which is narrower than the visual
     one -- 375px where the screen is 393. Stretching between two edges asks no such question.
     用 left 与 right 而不是宽度:这里的百分比是相对包含块算的,而移动版 WebKit 把那个包含块
     量成布局视口 —— 屏幕 393px 时它是 375px。在两条边之间拉开,则根本不问这个问题。 */
  .compose:not(.minimized) {
    inset: 0;
    width: auto; max-width: none;
    max-height: none; height: auto;
    border-radius: 0;
  }
  .compose:not(.minimized) .compose-head { border-radius: 0; }
  .compose:not(.minimized) .cp-editor.ql-container { min-height: 0; }
  /* Minimised keeps the old shape, at the foot of the screen and the full width of it. */
  /* 最小化保持原来的形状,在屏幕脚下,占满宽度。 */
  .compose.minimized { width: 100%; right: 0; border-radius: 0; }
}

/* ---------------------------------------------------------------------------
   Labels / 标签
   A fixed palette, deliberately independent of the 30 themes: a label's colour is
   what the user chose it to mean, and it must not shift when somebody repaints the
   interface. Each colour is given twice because a hue legible on white is not
   legible on near-black, and the one thing worse than an ugly label is one nobody
   can see.
   固定调色板,刻意与 30 套主题无关:标签的颜色承载的是用户赋予它的含义,
   不能因为有人换了界面配色就跟着变。每个颜色给两份 —— 在白底上看得清的色相,
   在近黑底上未必看得清;比难看的标签更糟的,是看不见的标签。
   --------------------------------------------------------------------------- */
html[data-webawesome] {
  --lb-amber: #f4b400; --lb-red: #e5484d; --lb-orange: #f76b15; --lb-green: #30a46c;
  --lb-teal: #12a594;  --lb-blue: #0090ff; --lb-indigo: #3e63dd; --lb-violet: #8e4ec6;
  --lb-pink: #d6409f;  --lb-gray: #8b8d98;
}
html[data-webawesome].wa-dark {
  --lb-amber: #ffc53d; --lb-red: #ff6369; --lb-orange: #ff8b3e; --lb-green: #3dd68c;
  --lb-teal: #0eb39e;  --lb-blue: #52a9ff; --lb-indigo: #7c8cf8; --lb-violet: #bf7af0;
  --lb-pink: #f65cb6;  --lb-gray: #b2b3bd;
}

/* The cell at the head of a row. Fixed width whether it holds nothing or three things,
   so the columns beside it stay aligned down the whole list.
   行首那一格。无论装 0 个还是 3 个,宽度固定,右边的列才能整列对齐。 */
.row-labels {
  flex: none; width: 44px; display: flex; align-items: center; gap: 1px;
  cursor: pointer; user-select: none;
}
.row-labels wa-icon { font-size: 17px; flex: none; }
.row-labels .lb-more { font-size: 11px; color: var(--text-3); font-weight: 600; }
.row-labels .lb-empty { color: var(--text-3); }
.row:hover .row-labels .lb-empty { color: var(--text-2); }

/* In the reading pane there is room for the name, and knowing which label is which
   matters more there than saving pixels.
   阅读区放得下名字,而且在那里"分清哪个是哪个"比省像素更重要。 */
.lb-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px 0 7px;
  border-radius: 999px; font-size: 12px; line-height: 1; white-space: nowrap;
  background: color-mix(in srgb, currentColor 14%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
}
.lb-chip wa-icon { font-size: 14px; }
.lb-chip .lb-x { opacity: .55; cursor: pointer; font-size: 13px; margin-left: 1px; }
.lb-chip .lb-x:hover { opacity: 1; }
.msg-labels { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }

/* The picker. Same shell as the context menu -- it is one, opened by a left click. */
/* 选择器。外壳与右键菜单相同 —— 它本来就是一个菜单,只是用左键打开。 */
.lb-pick { max-height: 320px; overflow-y: auto; }
.lb-pick .ctx-item .lb-box {
  flex: none; width: 16px; height: 16px; border-radius: 4px; margin-right: 2px;
  border: 1.5px solid var(--border-2); display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--primary-fg);
}
.lb-pick .ctx-item .lb-box.on { background: var(--primary); border-color: var(--primary); }
.lb-pick .ctx-item .lb-box.mixed { background: var(--primary); border-color: var(--primary); }
.lb-pick .ctx-item .lb-box.mixed::after { content: ''; width: 8px; height: 2px; background: var(--primary-fg); border-radius: 1px; }

/* Sidebar: the star row becomes a group header that opens and closes, and its labels
   sit one indent in. Clicking the header only folds -- what the list shows is decided
   by the label you click, not by the group.
   侧栏:星标那一行变成可开合的分组头,标签缩进一级。点分组头只管开合 ——
   右侧列什么由你点的那个标签决定,不由分组决定。 */
.side-item.group { cursor: pointer; }
.side-item .side-caret { flex: none; margin-left: auto; color: var(--text-3); transition: transform .15s; }
.side-item.open .side-caret { transform: rotate(90deg); }
.side-label { padding-left: 30px; gap: 10px; }
.side-label wa-icon { font-size: 17px; }
.side-label .side-count { color: var(--text-3); font-size: 12px; margin-left: auto; }
.side-label.active .side-count { color: var(--accent-text); }
.side-manage { padding-left: 30px; color: var(--text-3); font-size: 13px; }

/* The editor: colour and glyph are picked from what exists, never typed. */
/* 编辑器:颜色和字形都是从现成的里面挑,不给输入。 */
.lb-swatches, .lb-glyphs { display: flex; flex-wrap: wrap; gap: 6px; max-width: 300px; }
.lb-swatch {
  width: 24px; height: 24px; border-radius: 999px; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 12%, transparent);
}
.lb-swatch.on { border-color: var(--text); }
.lb-glyph {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: var(--text-2);
  border: 1px solid var(--border); background: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.lb-glyph.on { border-color: var(--text); background: var(--hover); }
.lb-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; }
.lb-row:hover { background: var(--hover); }
.lb-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A label's mark keeps its colour and its width anywhere it lands -- including inside a menu
   row, whose own rules would otherwise grey the glyph and let it push the text aside.
   标签记号无论放到哪里都保持自己的颜色和宽度 —— 包括菜单行里:
   那里的规则本会把字形涂灰,并让它把文字挤到一边去。 */
.lb-mark, .ctx-item > .lb-mark { display: inline-flex; flex: none; }
.lb-mark wa-icon { color: inherit !important; width: auto; }
/* Inside a menu row the mark stands where a plain icon would, so it carries the same trailing
   space that icon carries (0.75em of its own size) -- otherwise the labelled row's text starts
   further left than every other row's and the column of words stops being a column.
   菜单行里,记号站的是普通图标的位置,那就得带上普通图标同样的尾随留白(自身字号的 0.75em)——
   否则带标签那一行的文字会比其它行更靠左,那一列字就不成列了。 */
.ctx-item > .lb-mark wa-icon { margin-inline-end: 0.75em; }

/* The appearance popup: same shell as a menu, but a pair of grids rather than a list. */
/* 外观浮层:外壳与菜单相同,内容是两组网格而不是一列条目。 */
.lb-look { padding: 10px 12px; }
.lb-look-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.lb-look-row:last-child { margin-bottom: 0; }
.gm-look {
  width: 34px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.gm-look:hover { background: var(--hover); }
.gm-look wa-icon { color: inherit; }

/* ---------- 扮演他人时的顶部横幅 ----------
   Fixed to the top of the viewport and given its own strip of it: the shells below are 100vh
   tall, so the bar takes its height out of them rather than pushing the page down past the fold.
   固定在视口顶端,并且实实在在占掉一条:下面几个外壳都是 100vh 高,
   所以这条的高度是从它们身上减掉的,而不是把整页往下顶出屏幕。 */
.actas-bar {
  position: fixed; inset: var(--sat) 0 auto 0; height: 34px; z-index: 300;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 0 12px; font-size: 13px;
  background: var(--wa-color-warning-fill-loud); color: var(--wa-color-warning-on-loud);
  box-shadow: 0 1px 4px color-mix(in srgb, #000 22%, transparent);
}
.actas-bar wa-icon { font-size: 16px; flex: none; }
.actas-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actas-bar wa-button::part(base) {
  height: 24px; padding: 0 10px; font-size: 12px;
  background: color-mix(in srgb, #000 18%, transparent); color: inherit; border: none;
}
.actas-bar wa-button::part(base):hover { background: color-mix(in srgb, #000 30%, transparent); }
body.impersonating { padding-top: 34px; }
body.impersonating .shell { height: calc(100vh - 34px - var(--sat)); height: calc(100dvh - 34px - var(--sat)); }
body.impersonating .chat-shell { height: calc(100vh - 34px - var(--sat)); height: calc(100dvh - 34px - var(--sat)); }
body.impersonating .page,
body.impersonating .auth-wrap,
body.impersonating .boot-loading { min-height: calc(100vh - 34px - var(--sat)); min-height: calc(100dvh - 34px - var(--sat)); }
@media (max-width: 900px) {
  body.impersonating .sidebar { top: calc(94px + var(--sat)); }
}

/* ---------- 备份:三级包的并列清单 ---------- */
/* The console's Models page: the prompt box, its inputs, and the try-it output
   后台「大模型」页:提示词框、输入框、试一试的输出 */
.llm-prompt, .llm-in {
  border: 1px solid var(--border-2); border-radius: 8px; box-sizing: border-box;
  font: inherit; font-size: 13.5px; outline: none; background: var(--panel); color: var(--text);
}
.llm-in { height: 34px; padding: 0 11px; }
.llm-prompt { width: 100%; padding: 8px 11px; line-height: 1.5; resize: vertical; font-family: var(--font-code), ui-monospace, Consolas, monospace; font-size: 13px; }
.llm-prompt:focus, .llm-in:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--accent-soft); }
.llm-out {
  margin: 12px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--hover);
  font-family: var(--font-code), ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; max-width: 760px;
}

.bk-cols { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.bk-col { min-width: 250px; flex: 1; }
/* Each archive tier gets a real heading. These wore the sidebar's whisper-small title before,
   which under three columns of near-identical rows gave the eye nothing to anchor on.
   每一档归档配一个像样的标题。之前穿的是侧栏那件耳语大小的小标题,
   在三列几乎长得一样的行面前,眼睛没有可锚的东西。 */
.bk-cap { font-size: 14.5px; font-weight: 600; color: var(--text); padding: 2px 2px 8px; }
.bk-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px; border-radius: 8px; font-size: 13px;
}
.bk-row:hover { background: var(--hover); }
.bk-name { font-variant-numeric: tabular-nums; min-width: 92px; }
.bk-when { margin-left: auto; }
.bk-dl {
  display: inline-flex; align-items: center; color: var(--text-3);
  padding: 2px; border-radius: 6px; flex: none;
}
.bk-dl:hover { color: var(--primary); background: var(--selected); }

/* ---------- 备份:补档预览与导入后的提示 ---------- */
.bk-pend-rows { max-height: 260px; overflow-y: auto; margin: 2px 0 10px; }
.bk-pend-row {
  display: flex; align-items: baseline; gap: 16px;
  padding: 3px 6px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.bk-pend-row:hover { background: var(--hover); border-radius: 6px; }
.bk-pend-row .dim { margin-left: auto; }
.bk-hint {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  background: var(--wa-color-warning-fill-quiet); color: var(--wa-color-warning-on-quiet);
  border: 1px solid color-mix(in srgb, var(--wa-color-warning-fill-loud) 35%, transparent);
}
.bk-hint wa-icon { flex: none; }
.bk-hint a { color: inherit; font-weight: 600; text-decoration: underline; margin-left: auto; white-space: nowrap; }

/* 后台导航分组分隔线 / separators between the console's tab groups */
/* flex:none is the line itself. In the scrolling strip a 1px flex child is the first thing
   shrink takes, leaving its margins standing around nothing -- a gap where a line should be.
   flex:none 就是这条线本身。在横滚的条里,1px 的弹性子项是收缩第一个下手的对象,
   剩下两侧的 margin 围着一个不存在的东西站着 —— 该有线的地方只剩一道空隙。 */
.tab-sep { flex: none; width: 1px; align-self: stretch; background: var(--border); margin: 6px 8px; }

/* 登录信息里的地址与密码:等宽、可选中,给"抄下来"这件事让路 */
/* The address and password, monospaced and selectable -- this exists to be copied off a screen */
.pw-box {
  font-family: var(--font-code); font-size: 14px; letter-spacing: 0.02em;
  padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--hover); color: var(--text); user-select: all;
}
