/* 来信 · V0.2A 单一同源样式表（Fluent 2 晴空蓝纯浅色 + .lx-* 语义组件库）
 * 基线：UI规范/design-tokens.md (v1) · 技术设计 V0.2A
 * 约束：零构建、零外部资源；全部应用组件收敛于 .lx-* 前缀，避免污染 .lx-mail-body 邮件正文
 */

:root {
  color-scheme: light;

  /* 1. Surface / 画布与表面层级 */
  --lx-bg-canvas: #f5f5f5;
  --lx-bg-subtle: #fafafa;
  --lx-bg-surface: #ffffff;
  --lx-bg-hover: #f0f0f0;
  --lx-bg-pressed: #e6e6e6;
  --lx-bg-row-hover: #f4f8fe;

  /* 2. Text / 文字层级 */
  --lx-text-primary: #242424;
  --lx-text-secondary: #424242;
  --lx-text-muted: #616161;
  --lx-text-disabled: #9e9e9e;
  --lx-text-on-brand: #ffffff;

  /* 3. Brand / 晴空蓝（Crisp Sky） */
  --lx-brand-bg: #2374e1;
  --lx-brand-bg-hover: #1a62c4;
  --lx-brand-bg-pressed: #144fa1;
  --lx-brand-tint: #eef5fe;
  --lx-brand-tint-hover: #d9e9fd;
  --lx-brand-border: #bed8fb;
  --lx-brand-fg: #1754a8;

  /* 4. Border & Focus / 边框与焦点 */
  --lx-border-subtle: #e6e6e6;
  --lx-border-default: #d1d1d1;
  --lx-border-hover: #bdbdbd;
  --lx-border-input-bottom: #616161;
  --lx-focus-ring: #2374e1;

  /* 5. Semantic Status / 语义状态色 */
  --lx-success-bg: #f1faf1;
  --lx-success-border: #9fd89f;
  --lx-success-fg: #107c10;

  --lx-warning-bg: #fff9f5;
  --lx-warning-border: #fdceb0;
  --lx-warning-fg: #8a3707;

  --lx-danger-bg: #fdf3f4;
  --lx-danger-border: #eeacb2;
  --lx-danger-fg: #b10e1c;
  --lx-danger-solid: #c50f1f;
  --lx-danger-solid-hover: #a40d1a;

  --lx-neutral-badge-bg: #f0f0f0;
  --lx-neutral-badge-border: #dcdcdc;
  --lx-neutral-badge-fg: #424242;

  --lx-domain-alt-bg: #eef2f6;
  --lx-domain-alt-border: #cbd5e1;
  --lx-domain-alt-fg: #334155;

  /* 6. Typography / 字体与字阶 */
  --lx-font-sans: "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --lx-font-mono: "Cascadia Code", "JetBrains Mono", Consolas, "SFMono-Regular", ui-monospace, monospace;

  --lx-text-xs: 12px;
  --lx-text-sm: 13px;
  --lx-text-base: 14px;
  --lx-text-md: 16px;
  --lx-text-lg: 20px;
  --lx-text-xl: 24px;

  --lx-lh-xs: 16px;
  --lx-lh-sm: 18px;
  --lx-lh-base: 20px;
  --lx-lh-md: 22px;
  --lx-lh-lg: 28px;
  --lx-lh-xl: 32px;

  --lx-weight-regular: 400;
  --lx-weight-medium: 500;
  --lx-weight-semibold: 600;

  /* 7. Spacing / 4px 网格间距 */
  --lx-space-1: 4px;
  --lx-space-2: 8px;
  --lx-space-3: 12px;
  --lx-space-4: 16px;
  --lx-space-5: 20px;
  --lx-space-6: 24px;
  --lx-space-8: 32px;
  --lx-space-10: 40px;

  /* 8. Shape & Elevation / 圆角与阴影 */
  --lx-radius-sm: 4px;
  --lx-radius-md: 8px;
  --lx-radius-lg: 12px;
  --lx-radius-pill: 9999px;

  --lx-shadow-2: 0 0 2px rgba(0, 0, 0, 0.10), 0 1px 2px rgba(0, 0, 0, 0.08);
  --lx-shadow-4: 0 0 2px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.12);
  --lx-shadow-8: 0 0 2px rgba(0, 0, 0, 0.12), 0 4px 14px rgba(0, 0, 0, 0.12);

  /* 9. Layout & Motion / 布局与动效 */
  --lx-topbar-h: 52px;
  --lx-sidebar-w: 240px;
  --lx-content-max: 1360px;
  --lx-reading-max: 920px;

  --lx-ease: cubic-bezier(0.33, 0, 0.67, 1);
  --lx-duration-fast: 120ms;
}

/* ── Base Reset（不施加会污染邮件正文的组件级裸标签样式） ── */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--lx-bg-canvas);
  color: var(--lx-text-primary);
  font-family: var(--lx-font-sans);
  font-size: var(--lx-text-base);
  line-height: var(--lx-lh-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--lx-brand-fg);
  text-decoration: none;
  transition: color var(--lx-duration-fast) var(--lx-ease);
}

a:hover {
  color: var(--lx-brand-bg-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--lx-focus-ring);
  outline-offset: 2px;
}

h1, h2, h3, h4, p {
  margin: 0;
}

.lx-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Icons (.lx-icon) ── */
.lx-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  vertical-align: -0.15em;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lx-icon--lg {
  width: 20px;
  height: 20px;
}

.lx-icon--xl {
  width: 36px;
  height: 36px;
  stroke-width: 1.5;
}

/* ── App Shell / Topbar / Sidebar ── */
.lx-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--lx-bg-canvas);
}

.lx-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--lx-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lx-space-4);
  padding: var(--lx-space-2) var(--lx-space-5);
  background: var(--lx-bg-surface);
  border-bottom: 1px solid var(--lx-border-subtle);
}

.lx-topbar__left {
  display: flex;
  align-items: center;
  gap: var(--lx-space-3);
  min-width: calc(var(--lx-sidebar-w) - var(--lx-space-5));
  flex-shrink: 0;
}

.lx-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--lx-text-primary);
  font-weight: var(--lx-weight-semibold);
  font-size: 16px;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.lx-brand:hover {
  color: var(--lx-text-primary);
  text-decoration: none;
}

.lx-brand__mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--lx-brand-bg);
  color: var(--lx-text-on-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(35, 116, 225, 0.24);
  flex-shrink: 0;
}

.lx-brand__mark--lg {
  width: 32px;
  height: 32px;
}

.lx-brand__sub {
  font-size: var(--lx-text-xs);
  font-weight: var(--lx-weight-medium);
  color: var(--lx-text-muted);
  padding-left: 8px;
  border-left: 1px solid var(--lx-border-subtle);
  white-space: nowrap;
}

.lx-topbar__search {
  flex: 1;
  min-width: 0;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: var(--lx-space-1);
  height: 34px;
  padding: 0 var(--lx-space-1) 0 var(--lx-space-3);
  background: var(--lx-bg-canvas);
  border: 1px solid transparent;
  border-radius: var(--lx-radius-sm);
  transition: background var(--lx-duration-fast) var(--lx-ease),
              border-color var(--lx-duration-fast) var(--lx-ease),
              box-shadow var(--lx-duration-fast) var(--lx-ease);
}

.lx-topbar__search:hover {
  background: var(--lx-bg-hover);
}

.lx-topbar__search:focus-within {
  background: var(--lx-bg-surface);
  border-color: var(--lx-border-default);
  border-bottom: 2px solid var(--lx-brand-bg);
  box-shadow: var(--lx-shadow-4);
}

.lx-topbar__search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--lx-text-primary);
  font: inherit;
  padding: 0 4px;
  outline: none;
}

.lx-topbar__search-input::placeholder {
  color: var(--lx-text-muted);
}

.lx-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--lx-space-2);
  flex-shrink: 0;
}

.lx-admin-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--lx-radius-pill);
  background: var(--lx-bg-canvas);
  font-size: var(--lx-text-sm);
  color: var(--lx-text-secondary);
}

.lx-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--lx-radius-pill);
  background: var(--lx-brand-tint);
  color: var(--lx-brand-fg);
  font-size: 12px;
  font-weight: var(--lx-weight-semibold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lx-avatar--square {
  border-radius: 6px;
}

.lx-body {
  flex: 1;
  display: flex;
  min-width: 0;
  min-height: calc(100vh - var(--lx-topbar-h));
}

.lx-sidebar {
  width: var(--lx-sidebar-w);
  flex-shrink: 0;
  padding: var(--lx-space-4) var(--lx-space-3);
  background: var(--lx-bg-canvas);
  display: flex;
  flex-direction: column;
  gap: var(--lx-space-4);
}

.lx-compose-cta {
  width: 100%;
  height: 38px;
  justify-content: center;
  font-size: var(--lx-text-base);
  box-shadow: var(--lx-shadow-2);
}

.lx-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lx-nav-group__title {
  padding: 4px 10px 6px;
  font-size: 11px;
  font-weight: var(--lx-weight-semibold);
  letter-spacing: 0.04em;
  color: var(--lx-text-muted);
  text-transform: uppercase;
}

.lx-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 6px 10px 6px 12px;
  border-radius: var(--lx-radius-sm);
  color: var(--lx-text-secondary);
  font-size: var(--lx-text-base);
  font-weight: var(--lx-weight-regular);
  text-decoration: none;
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background var(--lx-duration-fast) var(--lx-ease),
              color var(--lx-duration-fast) var(--lx-ease);
}

.lx-nav-item:hover {
  background: var(--lx-bg-hover);
  color: var(--lx-text-primary);
  text-decoration: none;
}

.lx-nav-item.is-active,
.lx-nav-item[aria-current="page"] {
  background: var(--lx-brand-tint);
  color: var(--lx-brand-fg);
  font-weight: var(--lx-weight-semibold);
}

.lx-nav-item.is-active::before,
.lx-nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--lx-brand-bg);
}

.lx-nav-item__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lx-nav-item__label--mono {
  font-family: var(--lx-font-mono);
  font-size: var(--lx-text-sm);
}

/* Mobile zero-JS nav */
.lx-mobile-nav {
  display: none;
  background: var(--lx-bg-surface);
  border-bottom: 1px solid var(--lx-border-subtle);
}

.lx-mobile-nav > summary {
  list-style: none;
  padding: 10px 16px;
  font-weight: var(--lx-weight-medium);
  color: var(--lx-text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.lx-mobile-nav > summary::-webkit-details-marker {
  display: none;
}

.lx-mobile-nav__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lx-mobile-nav__state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--lx-text-xs);
  color: var(--lx-text-muted);
}

.lx-mobile-nav__state::before {
  content: "展开";
}

.lx-mobile-nav[open] .lx-mobile-nav__state::before {
  content: "收起";
}

.lx-mobile-nav__chevron {
  transition: transform var(--lx-duration-fast) var(--lx-ease);
}

.lx-mobile-nav[open] .lx-mobile-nav__chevron {
  transform: rotate(180deg);
}

.lx-mobile-nav__panel {
  padding: 8px 12px 16px;
  background: var(--lx-bg-canvas);
  border-top: 1px solid var(--lx-border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--lx-space-3);
}

/* Main Workspace */
.lx-workspace {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: var(--lx-space-4) var(--lx-space-5) var(--lx-space-6) var(--lx-space-2);
  display: flex;
  flex-direction: column;
}

.lx-panel {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  background: var(--lx-bg-surface);
  border: 1px solid var(--lx-border-subtle);
  border-radius: var(--lx-radius-lg);
  box-shadow: var(--lx-shadow-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lx-page-wrap {
  width: 100%;
  min-width: 0;
  max-width: var(--lx-content-max);
  display: flex;
  flex-direction: column;
  gap: var(--lx-space-4);
}

.lx-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--lx-space-4);
  flex-wrap: wrap;
}

.lx-page-title {
  font-size: var(--lx-text-lg);
  line-height: var(--lx-lh-lg);
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-primary);
}

.lx-page-subtitle {
  margin-top: 4px;
  font-size: var(--lx-text-sm);
  color: var(--lx-text-muted);
}

/* ── Command Bar (.lx-commandbar) ── */
.lx-commandbar {
  min-height: 50px;
  padding: var(--lx-space-2) var(--lx-space-4);
  background: var(--lx-bg-surface);
  border-bottom: 1px solid var(--lx-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lx-space-3);
  flex-wrap: wrap;
}

.lx-commandbar__group {
  display: flex;
  align-items: center;
  gap: var(--lx-space-2);
  flex-wrap: wrap;
  min-width: 0;
}

.lx-commandbar__heading {
  font-size: 15px;
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-primary);
}

.lx-commandbar__count {
  font-size: 12.5px;
  color: var(--lx-text-muted);
  font-variant-numeric: tabular-nums;
}

.lx-commandbar__filter {
  display: inline-flex;
  align-items: center;
  gap: var(--lx-space-2);
  flex-wrap: wrap;
  max-width: 100%;
}

.lx-commandbar__select {
  width: auto;
  min-width: 190px;
  max-width: 300px;
}

.lx-divider-v {
  width: 1px;
  height: 20px;
  background: var(--lx-border-subtle);
  margin: 0 2px;
}

/* ── Buttons (.lx-btn) ── */
.lx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--lx-radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--lx-text-sm);
  font-weight: var(--lx-weight-semibold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: background var(--lx-duration-fast) var(--lx-ease),
              border-color var(--lx-duration-fast) var(--lx-ease),
              color var(--lx-duration-fast) var(--lx-ease),
              box-shadow var(--lx-duration-fast) var(--lx-ease);
}

.lx-btn:hover {
  text-decoration: none;
}

.lx-btn--md {
  height: 36px;
  padding: 0 16px;
  font-size: var(--lx-text-base);
}

.lx-btn--sm {
  height: 28px;
  padding: 0 10px;
  font-size: var(--lx-text-xs);
}

.lx-btn--full {
  width: 100%;
}

.lx-btn--primary {
  background: var(--lx-brand-bg);
  color: var(--lx-text-on-brand);
  border-color: var(--lx-brand-bg);
}

.lx-btn--primary:hover {
  background: var(--lx-brand-bg-hover);
  border-color: var(--lx-brand-bg-hover);
  color: var(--lx-text-on-brand);
}

.lx-btn--primary:active {
  background: var(--lx-brand-bg-pressed);
}

.lx-btn--secondary {
  background: var(--lx-bg-surface);
  color: var(--lx-text-primary);
  border-color: var(--lx-border-default);
}

.lx-btn--secondary:hover {
  background: var(--lx-bg-hover);
  border-color: var(--lx-border-hover);
  color: var(--lx-text-primary);
}

.lx-btn--secondary:active {
  background: var(--lx-bg-pressed);
}

.lx-btn--subtle {
  background: transparent;
  color: var(--lx-text-secondary);
  border-color: transparent;
}

.lx-btn--subtle:hover {
  background: var(--lx-bg-hover);
  color: var(--lx-text-primary);
}

.lx-btn--danger {
  background: var(--lx-danger-solid);
  color: var(--lx-text-on-brand);
  border-color: var(--lx-danger-solid);
}

.lx-btn--danger:hover {
  background: var(--lx-danger-solid-hover);
  border-color: var(--lx-danger-solid-hover);
  color: var(--lx-text-on-brand);
}

.lx-btn--danger-outline {
  background: var(--lx-bg-surface);
  color: var(--lx-danger-fg);
  border-color: var(--lx-danger-border);
}

.lx-btn--danger-outline:hover {
  background: var(--lx-danger-bg);
  color: var(--lx-danger-fg);
}

.lx-btn:disabled,
.lx-btn.is-disabled {
  opacity: 0.48;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Form Layout Wrappers & Fields (.lx-field / .lx-input / .lx-select / .lx-textarea) ── */
.lx-inline-form {
  display: inline-flex;
  align-items: center;
}

.lx-inline-form > form {
  display: inline-flex;
  align-items: center;
  gap: var(--lx-space-2);
  flex-wrap: wrap;
  margin: 0;
}

.lx-form-wrap > form {
  display: flex;
  align-items: flex-end;
  gap: var(--lx-space-3);
  flex-wrap: wrap;
  margin: 0;
}

.lx-stack-form > form {
  display: flex;
  flex-direction: column;
  gap: var(--lx-space-4);
  margin: 0;
}

.lx-form-inline {
  display: flex;
  align-items: flex-end;
  gap: var(--lx-space-3);
  flex-wrap: wrap;
}

.lx-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.lx-field--grow {
  flex: 1;
  min-width: 180px;
}

.lx-field--w150 {
  width: 150px;
  max-width: 100%;
}

.lx-field--w180 {
  width: 180px;
  max-width: 100%;
}

.lx-field--w210 {
  width: 210px;
  max-width: 100%;
}

.lx-field__label {
  font-size: var(--lx-text-sm);
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-secondary);
}

.lx-field__hint {
  font-size: var(--lx-text-xs);
  color: var(--lx-text-muted);
}

.lx-field__error {
  font-size: var(--lx-text-xs);
  color: var(--lx-danger-fg);
  font-weight: var(--lx-weight-medium);
}

.lx-input,
.lx-select,
.lx-textarea {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  background: var(--lx-bg-surface);
  color: var(--lx-text-primary);
  font-family: inherit;
  font-size: var(--lx-text-base);
  border: 1px solid var(--lx-border-default);
  border-bottom: 1.5px solid var(--lx-border-input-bottom);
  border-radius: var(--lx-radius-sm);
  transition: border-color var(--lx-duration-fast) var(--lx-ease),
              box-shadow var(--lx-duration-fast) var(--lx-ease);
}

.lx-input--sm,
.lx-select--sm {
  min-height: 30px;
  padding: 4px 8px;
  font-size: var(--lx-text-sm);
}

.lx-input--mono {
  font-family: var(--lx-font-mono);
  font-size: var(--lx-text-sm);
}

.lx-input--pw {
  width: 185px;
  max-width: 100%;
}

.lx-input:hover,
.lx-select:hover,
.lx-textarea:hover {
  border-color: var(--lx-border-hover);
  border-bottom-color: var(--lx-text-secondary);
}

.lx-input:focus,
.lx-select:focus,
.lx-textarea:focus {
  outline: none;
  border-color: var(--lx-border-default);
  border-bottom: 2px solid var(--lx-brand-bg);
  box-shadow: 0 0 0 2px rgba(35, 116, 225, 0.14);
}

.lx-input[readonly] {
  background: var(--lx-bg-subtle);
  border-bottom-color: var(--lx-border-default);
  color: var(--lx-text-secondary);
}

.lx-input.is-error,
.lx-select.is-error {
  border-color: var(--lx-danger-border);
  border-bottom: 2px solid var(--lx-danger-solid);
  background: var(--lx-danger-bg);
}

.lx-textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.6;
}

/* ── Semantic Badges (.lx-badge) ── */
.lx-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: var(--lx-radius-pill);
  font-size: var(--lx-text-xs);
  font-weight: var(--lx-weight-medium);
  line-height: 1.3;
  white-space: nowrap;
  border: 1px solid transparent;
}

.lx-badge--mono {
  font-family: var(--lx-font-mono);
  font-size: 11.5px;
}

.lx-badge--wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}

.lx-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--lx-radius-pill);
  background: currentColor;
  flex-shrink: 0;
}

.lx-badge--brand {
  background: var(--lx-brand-tint);
  border-color: var(--lx-brand-border);
  color: var(--lx-brand-fg);
}

.lx-badge--domain-alt {
  background: var(--lx-domain-alt-bg);
  border-color: var(--lx-domain-alt-border);
  color: var(--lx-domain-alt-fg);
}

.lx-badge--success {
  background: var(--lx-success-bg);
  border-color: var(--lx-success-border);
  color: var(--lx-success-fg);
}

.lx-badge--warning {
  background: var(--lx-warning-bg);
  border-color: var(--lx-warning-border);
  color: var(--lx-warning-fg);
}

.lx-badge--danger {
  background: var(--lx-danger-bg);
  border-color: var(--lx-danger-border);
  color: var(--lx-danger-fg);
}

.lx-badge--neutral {
  background: var(--lx-neutral-badge-bg);
  border-color: var(--lx-neutral-badge-border);
  color: var(--lx-neutral-badge-fg);
}

/* ── Gmail-Style Full-Width Mail List (.lx-mail-list) ── */
.lx-mail-list-head {
  display: grid;
  grid-template-columns: 24px minmax(120px, 165px) minmax(0, 1.4fr) minmax(160px, 210px) minmax(72px, 108px) 84px;
  align-items: center;
  gap: var(--lx-space-3);
  padding: 8px var(--lx-space-4);
  background: var(--lx-bg-subtle);
  border-bottom: 1px solid var(--lx-border-subtle);
  font-size: var(--lx-text-xs);
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-muted);
}

.lx-mail-list-head__right {
  text-align: right;
}

.lx-mail-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lx-mail-row {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(120px, 165px) minmax(0, 1.4fr) minmax(160px, 210px) minmax(72px, 108px) 84px;
  align-items: center;
  gap: var(--lx-space-3);
  min-height: 46px;
  padding: 9px var(--lx-space-4);
  border-bottom: 1px solid var(--lx-border-subtle);
  background: var(--lx-bg-subtle);
  color: var(--lx-text-secondary);
  transition: background var(--lx-duration-fast) var(--lx-ease),
              box-shadow var(--lx-duration-fast) var(--lx-ease);
}

.lx-mail-row.is-unread {
  background: var(--lx-bg-surface);
  color: var(--lx-text-primary);
}

.lx-mail-row:hover {
  background: var(--lx-bg-row-hover);
  box-shadow: inset 3px 0 0 var(--lx-brand-bg);
}

.lx-mail-row:has(.lx-mail-row__link:focus-visible) {
  background: var(--lx-bg-row-hover);
  box-shadow: inset 3px 0 0 var(--lx-focus-ring);
}

.lx-mail-row:last-child {
  border-bottom: 0;
}

.lx-mail-row__status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lx-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--lx-radius-pill);
  background: var(--lx-brand-bg);
  display: inline-block;
}

.lx-mail-row__sender {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--lx-text-base);
}

.lx-mail-row.is-unread .lx-mail-row__sender,
.lx-mail-row.is-unread .lx-mail-row__link {
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-primary);
}

.lx-mail-row__main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lx-mail-row__link {
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}

.lx-mail-row__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.lx-mail-row__link:hover {
  color: var(--lx-brand-fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lx-mail-row__recipient {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}

.lx-mail-row__recipient .lx-badge {
  height: auto;
  min-height: 22px;
  padding: 3px 8px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
  max-width: 100%;
}

.lx-mail-row__folder {
  display: flex;
  align-items: center;
  min-width: 0;
}

.lx-mail-row__folder-link {
  position: relative;
  z-index: 2;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
  text-decoration: none;
}

.lx-mail-row__folder-link:hover {
  background: var(--lx-brand-tint);
  border-color: var(--lx-brand-border);
  color: var(--lx-brand-fg);
  text-decoration: none;
}

.lx-mail-row__time {
  text-align: right;
  font-size: var(--lx-text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--lx-text-muted);
  white-space: nowrap;
}

.lx-mail-row.is-unread .lx-mail-row__time {
  color: var(--lx-brand-fg);
  font-weight: var(--lx-weight-semibold);
}

/* ── Cards (.lx-card / .lx-subcard) ── */
.lx-card {
  min-width: 0;
  max-width: 100%;
  background: var(--lx-bg-surface);
  border: 1px solid var(--lx-border-subtle);
  border-radius: var(--lx-radius-md);
  box-shadow: var(--lx-shadow-2);
  overflow: hidden;
}

.lx-card--elevated {
  box-shadow: var(--lx-shadow-4);
}

.lx-card__header {
  padding: var(--lx-space-4) var(--lx-space-5);
  border-bottom: 1px solid var(--lx-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lx-space-3);
  flex-wrap: wrap;
}

.lx-card__title {
  font-size: var(--lx-text-md);
  line-height: var(--lx-lh-md);
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-primary);
}

.lx-card__desc {
  margin-top: 2px;
  font-size: var(--lx-text-sm);
  color: var(--lx-text-muted);
}

.lx-card__body {
  padding: var(--lx-space-5);
}

.lx-card__footer {
  padding: var(--lx-space-3) var(--lx-space-5);
  background: var(--lx-bg-subtle);
  border-top: 1px solid var(--lx-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lx-space-3);
  flex-wrap: wrap;
}

.lx-subcard {
  background: var(--lx-bg-surface);
  border: 1px solid var(--lx-border-default);
  border-radius: var(--lx-radius-md);
  padding: var(--lx-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--lx-space-3);
}

.lx-subcard--muted {
  background: var(--lx-bg-subtle);
}

.lx-subcard + .lx-subcard {
  margin-top: var(--lx-space-3);
}

.lx-subcard__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--lx-space-3);
  flex-wrap: wrap;
}

.lx-subcard__address {
  font-family: var(--lx-font-mono);
  font-size: 15px;
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-primary);
  overflow-wrap: anywhere;
}

.lx-subcard--muted .lx-subcard__address {
  color: var(--lx-text-muted);
}

.lx-subcard__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lx-space-3);
  flex-wrap: wrap;
  padding-top: var(--lx-space-3);
  border-top: 1px solid var(--lx-border-subtle);
}

/* ── KV Meta & Code Chips (.lx-kv / .lx-code) ── */
.lx-kv {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 8px 16px;
  font-size: var(--lx-text-sm);
}

.lx-kv__key {
  color: var(--lx-text-muted);
  font-weight: var(--lx-weight-medium);
}

.lx-kv__val {
  color: var(--lx-text-primary);
  overflow-wrap: anywhere;
  min-width: 0;
}

.lx-code {
  display: inline-block;
  padding: 2px 6px;
  background: var(--lx-bg-canvas);
  border: 1px solid var(--lx-border-subtle);
  border-radius: var(--lx-radius-sm);
  font-family: var(--lx-font-mono);
  font-size: 12.5px;
  color: var(--lx-text-primary);
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* ── Data Table (.lx-table-wrap / .lx-table) ── */
.lx-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.lx-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  text-align: left;
  font-size: var(--lx-text-sm);
}

.lx-table th {
  padding: 10px var(--lx-space-4);
  background: var(--lx-bg-subtle);
  border-bottom: 1px solid var(--lx-border-subtle);
  font-size: var(--lx-text-xs);
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-muted);
  white-space: nowrap;
}

.lx-table td {
  padding: 11px var(--lx-space-4);
  border-bottom: 1px solid var(--lx-border-subtle);
  color: var(--lx-text-primary);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.lx-table tbody tr:hover {
  background: var(--lx-bg-subtle);
}

.lx-table tbody tr:last-child td {
  border-bottom: 0;
}

.lx-table__num {
  font-variant-numeric: tabular-nums;
  color: var(--lx-text-muted);
  white-space: nowrap;
}

.lx-table__actions {
  text-align: right;
  white-space: nowrap;
}

/* ── Semantic Banners (.lx-banner) ── */
.lx-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--lx-radius-md);
  border: 1px solid transparent;
  border-left-width: 3px;
  font-size: var(--lx-text-sm);
  line-height: 1.5;
}

.lx-banner__content {
  min-width: 0;
  overflow-wrap: anywhere;
}

.lx-banner--info {
  background: var(--lx-brand-tint);
  border-color: var(--lx-brand-border);
  border-left-color: var(--lx-brand-bg);
  color: var(--lx-brand-fg);
}

.lx-banner--warning {
  background: var(--lx-warning-bg);
  border-color: var(--lx-warning-border);
  border-left-color: var(--lx-warning-fg);
  color: var(--lx-warning-fg);
}

.lx-banner--danger {
  background: var(--lx-danger-bg);
  border-color: var(--lx-danger-border);
  border-left-color: var(--lx-danger-solid);
  color: var(--lx-danger-fg);
}

.lx-banner--success {
  background: var(--lx-success-bg);
  border-color: var(--lx-success-border);
  border-left-color: var(--lx-success-fg);
  color: var(--lx-success-fg);
}

/* ── Confirmation Card (.lx-confirm) ── */
.lx-confirm {
  width: 100%;
  max-width: 560px;
  margin: var(--lx-space-6) auto;
  background: var(--lx-bg-surface);
  border: 1px solid var(--lx-danger-border);
  border-radius: var(--lx-radius-lg);
  box-shadow: var(--lx-shadow-8);
  overflow: hidden;
}

.lx-confirm__head {
  padding: var(--lx-space-4) var(--lx-space-5);
  background: var(--lx-danger-bg);
  border-bottom: 1px solid var(--lx-danger-border);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--lx-danger-fg);
}

.lx-confirm__title {
  font-size: var(--lx-text-md);
  font-weight: var(--lx-weight-semibold);
}

.lx-confirm__body {
  padding: var(--lx-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--lx-space-4);
}

.lx-confirm__list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--lx-text-secondary);
}

.lx-confirm__foot {
  padding: var(--lx-space-4) var(--lx-space-5);
  background: var(--lx-bg-subtle);
  border-top: 1px solid var(--lx-border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--lx-space-2);
  flex-wrap: wrap;
}

/* ── Empty State (.lx-empty) ── */
.lx-empty {
  padding: 52px var(--lx-space-6);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--lx-space-2);
  color: var(--lx-text-muted);
}

.lx-empty__title {
  font-size: var(--lx-text-md);
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-primary);
}

.lx-empty__desc {
  max-width: 480px;
  font-size: var(--lx-text-sm);
  color: var(--lx-text-muted);
  overflow-wrap: anywhere;
}

/* ── Pagination (.lx-pagination) ── */
.lx-pagination {
  padding: var(--lx-space-3) var(--lx-space-4);
  background: var(--lx-bg-subtle);
  border-top: 1px solid var(--lx-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lx-space-3);
  flex-wrap: wrap;
  font-size: var(--lx-text-sm);
  color: var(--lx-text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Mail Reading Container (P02 & A05 Quarantine Detail) ── */
.lx-reading-wrap {
  max-width: var(--lx-reading-max);
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: var(--lx-space-6);
  display: flex;
  flex-direction: column;
  gap: var(--lx-space-5);
}

.lx-reading-wrap--narrow {
  max-width: 780px;
}

.lx-reading-wrap--result {
  max-width: 640px;
}

.lx-mail-subject {
  font-size: 21px;
  line-height: 1.35;
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-primary);
  overflow-wrap: anywhere;
}

.lx-mail-meta-card {
  padding: var(--lx-space-4);
  background: var(--lx-bg-subtle);
  border: 1px solid var(--lx-border-subtle);
  border-radius: var(--lx-radius-md);
  min-width: 0;
}

/* Isolated mail body: protects page layout from Roundcube-washed sender HTML */
.lx-mail-body {
  min-width: 0;
  max-width: 100%;
  font-size: 15px;
  line-height: 1.72;
  color: var(--lx-text-primary);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.lx-mail-body h1,
.lx-mail-body h2,
.lx-mail-body h3,
.lx-mail-body h4 {
  margin: 16px 0 8px;
  line-height: 1.35;
}

.lx-mail-body p {
  margin: 0 0 12px;
}

.lx-mail-body ul,
.lx-mail-body ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.lx-mail-body a {
  color: var(--lx-brand-fg);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.lx-mail-body blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--lx-border-hover);
  background: var(--lx-bg-subtle);
  color: var(--lx-text-secondary);
}

.lx-mail-body img {
  max-width: 100%;
  height: auto;
  display: inline-block;
  border: 1px dashed var(--lx-border-default);
  background: var(--lx-bg-subtle);
  padding: 2px 6px;
  font-size: var(--lx-text-xs);
  color: var(--lx-text-muted);
}

.lx-mail-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: var(--lx-text-sm);
}

.lx-mail-body th,
.lx-mail-body td {
  padding: 6px 10px;
  border: 1px solid var(--lx-border-subtle);
  vertical-align: top;
  overflow-wrap: normal;
  word-break: normal;
}

.lx-mail-body th {
  white-space: nowrap;
  background: var(--lx-bg-subtle);
}

.lx-mail-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  margin: 0 0 12px;
  font-family: inherit;
}

.lx-attachments-section {
  padding-top: var(--lx-space-4);
  border-top: 1px solid var(--lx-border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--lx-space-3);
}

.lx-attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--lx-space-3);
}

.lx-attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--lx-bg-subtle);
  border: 1px solid var(--lx-border-default);
  border-radius: var(--lx-radius-md);
  color: var(--lx-text-primary);
  text-decoration: none;
  min-width: 0;
  transition: border-color var(--lx-duration-fast) var(--lx-ease),
              background var(--lx-duration-fast) var(--lx-ease);
}

.lx-attachment-item:hover {
  background: var(--lx-brand-tint);
  border-color: var(--lx-brand-border);
  text-decoration: none;
}

.lx-attachment-item__meta {
  min-width: 0;
  flex: 1;
}

.lx-attachment-item__name {
  display: block;
  font-weight: var(--lx-weight-medium);
  font-size: var(--lx-text-sm);
  overflow-wrap: anywhere;
}

.lx-attachment-item__hint {
  display: block;
  font-size: var(--lx-text-xs);
  color: var(--lx-text-muted);
}

/* ── Outbound Identity Mapping Preview Strip (P03) ── */
.lx-mapping-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--lx-space-3);
  padding: 12px 14px;
  background: var(--lx-brand-tint);
  border: 1px solid var(--lx-brand-border);
  border-radius: var(--lx-radius-md);
}

.lx-mapping-strip__item {
  min-width: 0;
}

.lx-mapping-strip__arrow {
  color: var(--lx-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lx-mapping-strip__label {
  font-size: 11px;
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-brand-fg);
  margin-bottom: 2px;
}

.lx-mapping-strip__addr {
  display: block;
  font-family: var(--lx-font-mono);
  font-size: var(--lx-text-sm);
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-primary);
  overflow-wrap: anywhere;
}

.lx-compose-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lx-space-3);
  flex-wrap: wrap;
  padding-top: var(--lx-space-3);
  border-top: 1px solid var(--lx-border-subtle);
}

/* ── Login Centered Shell (A01) ── */
.lx-auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--lx-space-6);
  background: radial-gradient(circle at top, var(--lx-brand-tint) 0%, var(--lx-bg-canvas) 55%);
}

.lx-auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--lx-bg-surface);
  border: 1px solid var(--lx-border-subtle);
  border-radius: var(--lx-radius-lg);
  box-shadow: var(--lx-shadow-8);
  padding: var(--lx-space-8);
  display: flex;
  flex-direction: column;
  gap: var(--lx-space-5);
}

.lx-auth-title {
  font-size: var(--lx-text-xl);
  line-height: var(--lx-lh-xl);
  font-weight: var(--lx-weight-semibold);
  color: var(--lx-text-primary);
}

/* ── Rule Row Card (A05) ── */
.lx-rule-item {
  padding: var(--lx-space-4) var(--lx-space-5);
  border-bottom: 1px solid var(--lx-border-subtle);
}

.lx-rule-item:last-child {
  border-bottom: 0;
}

.lx-rule-item__meta {
  display: flex;
  align-items: center;
  gap: var(--lx-space-2);
  flex-wrap: wrap;
  margin-bottom: var(--lx-space-3);
}

/* ── Utility Helpers ── */
.lx-stack-2 { display: flex; flex-direction: column; gap: var(--lx-space-2); }
.lx-stack-3 { display: flex; flex-direction: column; gap: var(--lx-space-3); }
.lx-stack-4 { display: flex; flex-direction: column; gap: var(--lx-space-4); }
.lx-row-2 { display: flex; align-items: center; gap: var(--lx-space-2); flex-wrap: wrap; }
.lx-row-3 { display: flex; align-items: center; gap: var(--lx-space-3); flex-wrap: wrap; }
.lx-row-end { display: flex; align-items: center; justify-content: flex-end; gap: var(--lx-space-2); flex-wrap: wrap; }
.lx-muted { color: var(--lx-text-muted); }
.lx-mono { font-family: var(--lx-font-mono); }
.lx-text-sm { font-size: var(--lx-text-sm); }
.lx-text-xs { font-size: var(--lx-text-xs); }

/* ── Responsive Breakpoints ── */
@media (max-width: 1199px) {
  .lx-sidebar {
    width: 216px;
  }
  .lx-topbar__left {
    min-width: 196px;
  }
  .lx-mail-list-head,
  .lx-mail-row {
    grid-template-columns: 20px minmax(100px, 130px) minmax(0, 1.3fr) minmax(136px, 180px) minmax(68px, 96px) 78px;
    gap: 10px;
    padding: 8px var(--lx-space-3);
  }
}

@media (max-width: 1023px) {
  .lx-sidebar {
    width: 208px;
  }
  .lx-topbar__left {
    min-width: auto;
  }
  .lx-brand__sub {
    display: none;
  }
  .lx-mail-list-head {
    display: none;
  }
  .lx-mail-row {
    grid-template-columns: 18px minmax(0, 1fr) auto;
    grid-template-areas:
      "dot sender time"
      "dot main main"
      "dot recipient folder";
    gap: 4px 8px;
    padding: 12px var(--lx-space-3);
  }
  .lx-mail-row__status { grid-area: dot; align-self: start; padding-top: 6px; }
  .lx-mail-row__sender { grid-area: sender; }
  .lx-mail-row__main { grid-area: main; }
  .lx-mail-row__recipient { grid-area: recipient; }
  .lx-mail-row__folder { grid-area: folder; justify-content: flex-end; }
  .lx-mail-row__time { grid-area: time; }
}

@media (max-width: 767px) {
  .lx-topbar {
    padding: var(--lx-space-2) var(--lx-space-3);
    gap: var(--lx-space-2);
    flex-wrap: wrap;
  }
  .lx-topbar__search {
    order: 3;
    flex: 1 0 100%;
    max-width: none;
  }
  .lx-admin-chip__name {
    display: none;
  }
  .lx-sidebar {
    display: none;
  }
  .lx-mobile-nav {
    display: block;
  }
  .lx-workspace {
    padding: var(--lx-space-3);
  }
  .lx-commandbar {
    padding: var(--lx-space-2) var(--lx-space-3);
  }
  .lx-commandbar__select {
    min-width: 0;
    flex: 1;
    max-width: 100%;
  }
  .lx-mapping-strip {
    grid-template-columns: 1fr;
  }
  .lx-mapping-strip__arrow {
    justify-content: flex-start;
    transform: rotate(90deg);
  }
  .lx-reading-wrap {
    padding: var(--lx-space-4);
  }
  .lx-card__header,
  .lx-card__body,
  .lx-card__footer {
    padding-left: var(--lx-space-4);
    padding-right: var(--lx-space-4);
  }
  .lx-kv {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .lx-auth-card {
    padding: var(--lx-space-6);
  }
}
