/* Material 3 baseline (Android native style), seed #6750A4.
   Legacy --bg/--panel/--accent aliases map onto M3 roles so existing
   components keep working; new code should use the --m3-* roles. */
:root {
  color-scheme: dark;
  /* M3 dark roles */
  --m3-primary: #d0bcff;
  --m3-on-primary: #381e72;
  --m3-primary-container: #4f378b;
  --m3-on-primary-container: #eaddff;
  --m3-secondary: #ccc2dc;
  --m3-on-secondary: #332d41;
  --m3-secondary-container: #4a4458;
  --m3-on-secondary-container: #e8def8;
  --m3-tertiary: #efb8c8;
  --m3-on-tertiary: #492532;
  --m3-tertiary-container: #633b48;
  --m3-on-tertiary-container: #ffd8e4;
  --m3-error: #ffb4ab;
  --m3-on-error: #690005;
  --m3-error-container: #93000a;
  --m3-on-error-container: #ffdad6;
  --m3-surface: #141218;
  --m3-on-surface: #e6e0e9;
  --m3-surface-variant: #49454f;
  --m3-on-surface-variant: #cac4d0;
  --m3-surface-container-lowest: #0f0d13;
  --m3-surface-container-low: #1d1b20;
  --m3-surface-container: #211f26;
  --m3-surface-container-high: #2b2930;
  --m3-surface-container-highest: #36343b;
  --m3-outline: #938f99;
  --m3-outline-variant: #49454f;
  --m3-inverse-surface: #e6e0e9;
  --m3-inverse-on-surface: #322f35;
  --m3-inverse-primary: #6750a4;
  --m3-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 3px 1px rgba(0, 0, 0, 0.3);
  --m3-elevation-2: 0 1px 2px rgba(0, 0, 0, 0.5), 0 2px 6px 2px rgba(0, 0, 0, 0.3);
  --m3-elevation-3: 0 4px 8px 3px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  --m3-scrim: #000000;
  --m3-shadow: #000000;

  /* M3 shape scale */
  --m3-shape-xs: 4px;
  --m3-shape-sm: 8px;
  --m3-shape-md: 12px;
  --m3-shape-lg: 16px;
  --m3-shape-xl: 28px;
  --m3-shape-full: 999px;

  --bg-0: var(--m3-surface);
  --bg-1: var(--m3-surface-container-low);
  --bg-2: var(--m3-surface-container);
  --panel: var(--m3-surface-container-low);
  --panel-strong: var(--m3-surface-container);
  --panel-2: var(--m3-surface-container);
  --panel-3: var(--m3-surface-container-high);
  --line: var(--m3-outline-variant);
  --line-strong: var(--m3-outline);
  --text: var(--m3-on-surface);
  --text-2: var(--m3-on-surface-variant);
  --text-3: var(--m3-on-surface-variant);
  --muted: var(--m3-outline);
  --accent: var(--m3-primary);
  --accent-2: var(--m3-tertiary);
  --accent-text: var(--m3-primary);
  --on-accent: var(--m3-on-primary);
  --accent-2-text: var(--m3-on-tertiary-container);
  --mint: #32b393;
  --mint-text: #5ad2b2;
  --danger: var(--m3-error);
  --danger-text: var(--m3-error);
  /* Issue #377: destructive actions read as a solid red instead of the pale
     M3 error tint, so the warning stays unmistakable on a dark surface. */
  --danger-solid: #b3261e;
  --on-danger-solid: #ffffff;
  --warning: #e3b341;
  --info: var(--m3-inverse-primary);
  --scrollbar-track: transparent;
  --scrollbar-thumb: var(--m3-outline-variant);
  --scrollbar-thumb-strong: var(--m3-outline);
  --shadow: var(--m3-elevation-2);
  --overlay-soft: rgba(0, 0, 0, 0.5);
  --radius-lg: var(--m3-shape-md);
  --radius-md: var(--m3-shape-sm);
  --radius-sm: var(--m3-shape-xs);
  --mobile-system-bar-height: 28px;
  /* #436：Android WebView 常把 env(safe-area-inset-*) 报成 0，原生层用
     WindowInsetsCompat 量出的系统栏 / 挖孔高度经 --native-inset-* 传进来。
     两者取较大值，不相加：能正确报告安全区域的 WebView 结果不变。
     额外留白（--user-inset-*）在这个基础上再加。 */
  --safe-area-top: calc(max(env(safe-area-inset-top, 0px), var(--native-inset-top, 0px)) + var(--user-inset-top, 0px));
  --safe-area-right: max(env(safe-area-inset-right, 0px), var(--native-inset-right, 0px));
  --safe-area-bottom: calc(max(env(safe-area-inset-bottom, 0px), var(--native-inset-bottom, 0px)) + var(--user-inset-bottom, 0px));
  --safe-area-left: max(env(safe-area-inset-left, 0px), var(--native-inset-left, 0px));
}

:root[data-theme="light"] {
  color-scheme: light;
    --font-sans: "Roboto", "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", "Segoe UI", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;

  /* M3 light roles */
  --m3-primary: #6750a4;
  --m3-on-primary: #ffffff;
  --m3-primary-container: #eaddff;
  --m3-on-primary-container: #4f378b;
  --m3-secondary: #625b71;
  --m3-on-secondary: #ffffff;
  --m3-secondary-container: #e8def8;
  --m3-on-secondary-container: #4a4458;
  --m3-tertiary: #7d5260;
  --m3-on-tertiary: #ffffff;
  --m3-tertiary-container: #ffd8e4;
  --m3-on-tertiary-container: #633b48;
  --m3-error: #ba1a1a;
  --m3-on-error: #ffffff;
  --m3-error-container: #ffdad6;
  --m3-on-error-container: #93000a;
  --m3-surface: #fef7ff;
  --m3-on-surface: #1d1b20;
  --m3-surface-variant: #e7e0ec;
  --m3-on-surface-variant: #45414b; /* #49454f 叠 78%（说明文字）在 container-high 上只有 4.43:1 */
  --m3-surface-container-lowest: #ffffff;
  --m3-surface-container-low: #f7f2fa;
  --m3-surface-container: #f3edf7;
  --m3-surface-container-high: #ece6f0;
  --m3-surface-container-highest: #e6e0e9;
  --m3-outline: #79747e;
  --m3-outline-variant: #cac4d0;
  --m3-inverse-surface: #322f35;
  --m3-inverse-on-surface: #f5eff7;
  --m3-inverse-primary: #d0bcff;
  --m3-scrim: #000000;
  --m3-shadow: #000000;

  /* M3 shape scale */
  --m3-shape-xs: 4px;
  --m3-shape-sm: 8px;
  --m3-shape-md: 12px;
  --m3-shape-lg: 16px;
  --m3-shape-xl: 28px;
  --m3-shape-full: 999px;

  /* M3 elevation (light) */
  --m3-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
  --m3-elevation-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
  --m3-elevation-3: 0 4px 8px 3px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.3);

  /* Legacy aliases */
  --bg-0: var(--m3-surface);
  --bg-1: var(--m3-surface-container-low);
  --bg-2: var(--m3-surface-container);
  --panel: var(--m3-surface-container-low);
  --panel-strong: var(--m3-surface-container);
  --panel-2: var(--m3-surface-container);
  --panel-3: var(--m3-surface-container-high);
  --line: var(--m3-outline-variant);
  --line-strong: var(--m3-outline);
  --text: var(--m3-on-surface);
  --text-2: var(--m3-on-surface-variant);
  --text-3: var(--m3-on-surface-variant);
  --muted: var(--m3-outline);
  --accent: var(--m3-primary);
  --accent-2: var(--m3-tertiary);
  --accent-text: var(--m3-primary);
  --on-accent: var(--m3-on-primary);
  --accent-2-text: var(--m3-on-tertiary-container);
  --mint: #168268;
  --mint-text: #106b57;
  --danger: var(--m3-error);
  --danger-text: var(--m3-error);
  /* Issue #377: same solid red in the light theme. */
  --danger-solid: #ba1a1a;
  --on-danger-solid: #ffffff;
  --warning: #9a6b00;
  --info: var(--m3-primary);
  --scrollbar-track: transparent;
  --scrollbar-thumb: var(--m3-outline-variant);
  --scrollbar-thumb-strong: var(--m3-outline);
  --shadow: var(--m3-elevation-2);
  --overlay-soft: rgba(29, 27, 32, 0.4);
  --radius-lg: var(--m3-shape-md);
  --radius-md: var(--m3-shape-sm);
  --radius-sm: var(--m3-shape-xs);
  --mobile-system-bar-height: 28px;
  /* #436：Android WebView 常把 env(safe-area-inset-*) 报成 0，原生层用
     WindowInsetsCompat 量出的系统栏 / 挖孔高度经 --native-inset-* 传进来。
     两者取较大值，不相加：能正确报告安全区域的 WebView 结果不变。
     额外留白（--user-inset-*）在这个基础上再加。 */
  --safe-area-top: calc(max(env(safe-area-inset-top, 0px), var(--native-inset-top, 0px)) + var(--user-inset-top, 0px));
  --safe-area-right: max(env(safe-area-inset-right, 0px), var(--native-inset-right, 0px));
  --safe-area-bottom: calc(max(env(safe-area-inset-bottom, 0px), var(--native-inset-bottom, 0px)) + var(--user-inset-bottom, 0px));
  --safe-area-left: max(env(safe-area-inset-left, 0px), var(--native-inset-left, 0px));
}

* {
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
  padding: 0;
  letter-spacing: 0;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-sans);
}

body.app-booting,
body.dialog-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color-scheme: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  /* 与 foundation.css 的禁用按钮一致：羊皮纸等浅色阅读配色下文字仍 ≥ 3:1。 */
  opacity: 0.7;
}

input::placeholder,
textarea::placeholder {
  /* --muted 在深色界面是描边色，压在输入框底色上不到 4.5:1。 */
  color: var(--text-2);
  opacity: 1;
}

select,
option {
  background: var(--bg-1);
  color: var(--text);
}

[hidden],
.hidden {
  display: none !important;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.nav-item:focus-visible,
.result-card:focus-visible,
.history-action:focus-visible,
.bookshelf-open-area:focus-visible {
  outline: 2px solid var(--m3-primary);
  outline-offset: 2px;
}

/* M3 cards: tonal filled containers, no harsh borders. */
.panel-shell,
.result-card,
.summary-chip,
.book-detail-panel {
  min-width: 0;
  border: 0;
  border-radius: var(--m3-shape-lg);
  background: var(--m3-surface-container-low);
  box-shadow: none;
}

.panel-inset {
  border: 0;
  border-radius: var(--m3-shape-md);
  background: var(--m3-surface-container-high);
}

.section-title,
.result-title,
.detail-title,
.history-title,
.job-title,
.brand-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-sans);
}

.section-meta,
.list-meta,
.job-meta,
.result-meta,
.detail-meta,
.history-meta,
.field-hint,
.book-detail-empty,
.empty-state {
  color: var(--muted);
}

.section-title {
  font-size: 16px;
  font-weight: 700;
}

.section-meta,
.list-meta,
.job-meta,
.result-meta,
.detail-meta,
.history-meta,
.field-hint {
  font-size: 12px;
  line-height: 1.5;
}

.section-meta,
.job-meta,
.result-meta,
.detail-meta,
.history-meta {
  margin-top: 4px;
}

.button-row,
.history-actions,
.job-foot,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* M3 buttons: filled / tonal / outlined / text, full-round label. */
.accent-button,
.ghost-button,
.danger-button,
.history-action,
.update-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 40px;
  /* Issue #377: font-size is inherited, so a button that does not sit inside a
     .button-row (the 选择目录 button in .path-picker, for example) fell back to
     the base 16px and looked like a different component next to the 14px pills.
     Pin it to the same global option-size variable the button rows use. */
  font-size: var(--app-option-font, 14px);
  padding: 0 24px;
  line-height: 1.2;
  white-space: nowrap;
  font-weight: 500;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}


.accent-button:hover {
  box-shadow: var(--m3-elevation-1);
  filter: brightness(1.08);
}

.ghost-button:hover,
.history-action:hover {
  box-shadow: var(--m3-elevation-1);
  filter: brightness(1.04);
}

.danger-button {
  background: var(--m3-error);
  color: var(--m3-on-error);
  font-weight: 500;
}

/* M3 outlined text field. */
.text-input,
.text-area,
select.text-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-shape-xs);
  background: transparent;
  color: var(--text);
}

.text-input:focus,
.text-area:focus,
select.text-input:focus {
  border-color: var(--m3-primary);
  outline: 1px solid var(--m3-primary);
}

.text-input,
select.text-input {
  min-height: 40px;
  padding: 0 16px;
}

.text-area {
  min-height: 180px;
  padding: 10px 16px;
  resize: vertical;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

/* M3 switch (CSS-only, keeps the native checkbox for a11y). */
.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.switch-row input {
  appearance: none;
  width: 52px;
  height: 32px;
  flex: 0 0 52px;
  border: 2px solid var(--m3-outline);
  border-radius: var(--m3-shape-full);
  background: var(--m3-surface-container-highest);
  cursor: pointer;
  position: relative;
  transition: background 140ms ease, border-color 140ms ease;
  accent-color: var(--m3-primary);
}

.switch-row input::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--m3-outline);
  transform: translateY(-50%);
  transition: left 140ms ease, width 140ms ease, background 140ms ease;
}

.switch-row input:checked {
  border-color: var(--m3-primary);
  background: var(--m3-primary);
}

.switch-row input:checked::after {
  left: 24px;
  width: 24px;
  height: 24px;
  background: var(--m3-on-primary);
}

.path-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
}

.path-display {
  display: block;
  min-width: 0;
  min-height: 40px;
  padding: 9px 16px;
  overflow: hidden;
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-shape-xs);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* M3 segmented buttons. */
.format-toggle {
  display: grid;
  /* auto-fit gives one column per button whatever the count. The old
     repeat(2, minmax(0, 1fr)) silently wrapped the third and fourth choices of
     every group that had more than two onto an orphan second row. */
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  width: min(240px, 100%);
  gap: 0;
  padding: 0;
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-shape-full);
  /* Issue #379: the unselected segment has to be visibly different from the
     selected one. A transparent background let it fall through to whatever the
     surrounding surface happens to be, and on the Windows Fluent theme that
     surface (#333) is all but identical to the selected pill (#2e2e2e) — the
     reader could not tell which option was active. Painting the track with the
     variant surface keeps the two states apart on every theme, including light
     mode where both used to collapse to the same #ececec. */
  background: var(--m3-surface-variant);
  overflow: hidden;
}

.format-toggle.official-bookshelf-filters {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* The local filter has two choices. It used to share the three-column rule
   above, which left an empty third cell beside 全部 | 分组. */
.format-toggle.local-bookshelf-filters {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Empty and loading notes span every column of whatever grid they land in
   (bookshelf, results, history) instead of squeezing into the first card cell. */
.empty-state,
.loading-state {
  grid-column: 1 / -1;
}

.format-toggle-button {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-left: 1px solid var(--m3-outline);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.format-toggle-button:first-child {
  border-left: 0;
}

.format-toggle-button:hover {
  background: color-mix(in srgb, var(--m3-on-surface) 8%, transparent);
}

.format-toggle-button.active,
.format-toggle-button[aria-pressed="true"] {
  background: var(--m3-secondary-container);
  color: var(--m3-on-secondary-container);
}

/* M3 assist chips. */
.status-pill,
.meta-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 32px;
  padding: 0 16px;
  overflow: hidden;
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-shape-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.success {
  border-color: transparent;
  background: var(--m3-tertiary-container);
  color: var(--m3-on-tertiary-container);
}

.status-pill.warning {
  border-color: transparent;
  background: var(--m3-secondary-container);
  color: var(--m3-on-secondary-container);
}

.status-pill.danger {
  background: var(--m3-error-container);
  border-color: transparent;
  color: var(--m3-on-error-container);
}

.status-pill.info {
  border-color: transparent;
  background: var(--m3-primary-container);
  color: var(--m3-on-primary-container);
}

.status-pill.loading-pill {
  gap: 6px;
}

/* M3 linear progress. */
.progress-track {
  width: 100%;
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: var(--m3-shape-full);
  background: var(--m3-surface-container-highest);
}

.progress-bar,
.update-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--m3-primary);
}

.empty-state,
.book-detail-empty,
.loading-state {
  min-width: 0;
  padding: 16px 12px;
  border: 0;
  border-radius: var(--m3-shape-md);
  background: var(--m3-surface-container);
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 180px;
}

.loading-spinner,
.busy-spinner,
.inline-spinner {
  display: inline-block;
  flex: 0 0 auto;
  border: 2px solid var(--m3-surface-container-highest);
  border-top-color: var(--m3-primary);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.loading-spinner,
.busy-spinner {
  width: 18px;
  height: 18px;
}

.inline-spinner {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
}

.warning-text {
  color: var(--warning);
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  background: var(--scrollbar-thumb);
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-strong);
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* Fluent 2 baseline for Windows desktops (issue #305). The Android M3
   baseline above stays untouched; this block only retokens surfaces the
   Windows shell shares with M3 roles. Layout, radii scale names and
   component structure are unchanged. */
body.windows-shell {
  --font-sans: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;

  /* Fluent shape: tighter corners than M3. */
  --m3-shape-xs: 4px;
  --m3-shape-sm: 4px;
  --m3-shape-md: 6px;
  --m3-shape-lg: 8px;
  --m3-shape-xl: 12px;
  --m3-shape-full: 999px;
  --radius-lg: 6px;
  --radius-md: 4px;
  --radius-sm: 4px;

  /* Fluent dark (Win11 #202020 family, accent #4cc2ff). */
  --m3-primary: #4cc2ff;
  --m3-on-primary: #000000;
  --m3-primary-container: #00395e;
  --m3-on-primary-container: #c7e9ff;
  --m3-secondary-container: #2e2e2e;
  --m3-on-secondary-container: #ffffff;
  --m3-tertiary-container: #3a2d3f;
  --m3-on-tertiary-container: #f5d6f2;
  --m3-error: #ff99a4;
  --m3-on-error: #4d0006;
  --m3-error-container: #7a0021;
  --m3-on-error-container: #ffdbe0;
  --m3-surface: #202020;
  --m3-on-surface: #ffffff;
  --m3-on-surface-variant: #c7c7c7;
  --m3-surface-container-lowest: #101010;
  --m3-surface-container-low: #2b2b2b;
  --m3-surface-container: #2c2c2c;
  --m3-surface-container-high: #333333;
  --m3-surface-container-highest: #3a3a3a;
  --m3-outline: #767676;
  --m3-outline-variant: #404040;
  --m3-inverse-surface: #f3f3f3;
  --m3-inverse-on-surface: #101010;
  --m3-inverse-primary: #0067c0;
  --m3-scrim: #000000;
  --m3-shadow: #000000;
  --m3-elevation-1: 0 2px 4px rgba(0, 0, 0, 0.4);
  --m3-elevation-2: 0 4px 12px rgba(0, 0, 0, 0.45);
  --m3-elevation-3: 0 8px 24px rgba(0, 0, 0, 0.5);
}

:root[data-theme="light"] body.windows-shell {
  /* Fluent light (Win11 #f3f3f3 family, accent #0067c0). */
  --m3-primary: #0067c0;
  --m3-on-primary: #ffffff;
  --m3-primary-container: #cfe6ff;
  --m3-on-primary-container: #00395e;
  --m3-secondary-container: #ececec;
  --m3-on-secondary-container: #101010;
  --m3-tertiary-container: #f6e4f3;
  --m3-on-tertiary-container: #4a2348;
  --m3-error: #c42b1c;
  --m3-on-error: #ffffff;
  --m3-error-container: #fdeceb;
  --m3-on-error-container: #7a0021;
  --m3-surface: #f3f3f3;
  --m3-on-surface: #101010;
  /* #4d4d4d 叠 78% 透明（--ds-text-subtle）后在 #e4e4e4 上只有约 4.0:1，说明文字发灰看不清。 */
  --m3-on-surface-variant: #404040;
  --m3-surface-container-lowest: #ffffff;
  --m3-surface-container-low: #f9f9f9;
  --m3-surface-container: #f3f3f3;
  --m3-surface-container-high: #ececec;
  --m3-surface-container-highest: #e4e4e4;
  --m3-outline: #767676;
  --m3-outline-variant: #d4d4d4;
  --m3-inverse-surface: #202020;
  --m3-inverse-on-surface: #ffffff;
  --m3-inverse-primary: #4cc2ff;
  --m3-elevation-1: 0 2px 4px rgba(0, 0, 0, 0.14);
  --m3-elevation-2: 0 4px 12px rgba(0, 0, 0, 0.16);
  --m3-elevation-3: 0 8px 24px rgba(0, 0, 0, 0.18);
}

/* Classic theme (issue #317): the pre-Material-3 tomato-red palette with compact
   radii. Placed after the M3/Fluent blocks so its legacy aliases win;
   M3 roles are retokened too so M3-only components follow the classic look.
   Toggle via the top-bar theme button: dark -> light -> classic.
   用户要求把「默认」配色和「经典」对调：经典保留自己的深色底和紧凑圆角，
   但强调色换回默认的 M3 紫色（以前那套番茄强调色搬到了「默认」配色上）。 */
:root[data-theme="classic"] {
  color-scheme: dark;
  --m3-primary: #d0bcff;
  --m3-on-primary: #381e72;
  --m3-primary-container: #4f378b;
  --m3-on-primary-container: #eaddff;
  --m3-secondary: #ccc2dc;
  --m3-on-secondary: #332d41;
  --m3-secondary-container: #4a4458;
  --m3-on-secondary-container: #e8def8;
  --m3-tertiary: #32b393;
  --m3-on-tertiary: #06231b;
  --m3-tertiary-container: #0e3f32;
  --m3-on-tertiary-container: #b9e8d8;
  --m3-error: #e76363;
  --m3-on-error: #2b0606;
  --m3-error-container: #5c1515;
  --m3-on-error-container: #ffdada;
  --m3-surface: #111416;
  --m3-on-surface: #f1f4f2;
  --m3-surface-variant: #1d2326;
  --m3-on-surface-variant: #c9d1ce;
  --m3-surface-container-lowest: #0d1012;
  --m3-surface-container-low: #171b1e;
  --m3-surface-container: #1b2023;
  --m3-surface-container-high: #20272b;
  --m3-surface-container-highest: #252c30;
  --m3-outline: #52616a;
  --m3-outline-variant: #374148;
  --m3-inverse-surface: #f1f4f2;
  --m3-inverse-on-surface: #18201d;
  --m3-inverse-primary: #6750a4;
  --m3-shape-xs: 4px;
  --m3-shape-sm: 6px;
  --m3-shape-md: 8px;
  --m3-shape-lg: 10px;
  --m3-shape-xl: 14px;
  --m3-shape-full: 999px;

  --bg-0: #111416;
  --bg-1: #171b1e;
  --bg-2: #1b2023;
  --panel: #1d2326;
  --panel-strong: #252c30;
  --panel-2: #20272b;
  --panel-3: #2a3237;
  --line: #374148;
  --line-strong: #52616a;
  --text: #f1f4f2;
  --text-2: #c9d1ce;
  --text-3: #a5b0ac;
  --muted: #91a09b;
  --accent: #d0bcff;
  --accent-2: #efb8c8;
  --accent-text: #d0bcff;
  --accent-2-text: #ffd8e4;
  --on-accent: #381e72;
  --mint: #32b393;
  --mint-text: #5ad2b2;
  --danger: #e76363;
  --danger-text: #ff9b9b;
  --danger-solid: #c0392b;
  --on-danger-solid: #ffffff;
  --warning: #e3b341;
  --info: #6aa8e8;
  --scrollbar-track: #171b1e;
  --scrollbar-thumb: #58656b;
  --scrollbar-thumb-strong: #76858c;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  --overlay-soft: rgba(9, 12, 14, 0.82);
  --radius-lg: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;
}

/* Classic now owns the M3 purple accent, so on Windows the neutralization
   keeps the purple instead of retinting it Fluent blue. */
:root[data-theme="classic"] body.windows-shell {
  --m3-primary: #d0bcff;
  --m3-on-primary: #381e72;
  --m3-primary-container: #4f378b;
  --m3-on-primary-container: #eaddff;
  --m3-inverse-primary: #6750a4;
  --m3-surface: #1d2326;
  --m3-on-surface: #f1f4f2;
  --m3-on-surface-variant: #c9d1ce;
  --m3-surface-container-low: #171b1e;
  --m3-surface-container: #1b2023;
  --m3-surface-container-high: #20272b;
  --m3-surface-container-highest: #252c30;
  --m3-outline: #52616a;
  --m3-outline-variant: #374148;
  --m3-shape-xs: 4px;
  --m3-shape-sm: 6px;
  --m3-shape-md: 8px;
  --m3-shape-lg: 10px;
  --m3-shape-xl: 14px;
  --radius-lg: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;
}
