/* mf-dark:skip — v0.9.7 theme layer, written by hand for both themes.
 * Most dark styling is derived automatically (server/v097-theme-css.mjs adds a dark twin beside every
 * colour declaration). This file holds what cannot be derived from a single declaration:
 *   1. the base canvas, native controls and the version bar;
 *   2. semantic exceptions (page canvas, elevation, icons delivered as images);
 *   3. the 外观设置 panel in the personal centre.
 * Tokens (--mf-color-*) come from v097-theme-tokens.css. Rules: docs/v097/暗黑模式UI规范.md. */

/* ---- 1. Base ------------------------------------------------------------ */
html[data-theme="dark"] {
  color-scheme: dark;
  background: var(--mf-color-background-canvas);
  scrollbar-color: #4d4c49 transparent;
}
html[data-theme="dark"] body { background: var(--mf-color-background-canvas); color: var(--mf-color-text-primary); }
html[data-theme="dark"] ::selection { background: rgba(49, 135, 255, 0.36); color: #ffffff; }
html[data-theme="dark"] :focus-visible { outline-color: #70aaff; }
html[data-theme="dark"] ::placeholder { color: #5d5c58; }

/* Version bar: follows the theme like the rest of the application. In a segmented control the selected
   item must be lighter than its track, which the per-declaration mapping cannot know. */
html[data-theme="dark"] .home-topbar.home-topbar { background: var(--mf-color-background-surface); border-bottom-color: var(--mf-color-border-subtle); }
html[data-theme="dark"] .home-topbar .home-mode-tabs { background: var(--mf-color-background-canvas); }
html[data-theme="dark"] .home-mode-tabs .home-mode-tabs__tab[aria-selected="true"] { background: var(--mf-color-surface-tertiary); color: var(--mf-color-text-primary); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06); }
html[data-theme="dark"] .home-topbar .home-version-select select option { background: var(--mf-color-background-surface); color: var(--mf-color-text-primary); }

/* ---- 2. Semantic exceptions --------------------------------------------- */
/* Page canvas: the layer behind every surface is the darkest one (background/canvas). */
html[data-theme="dark"] :is(.app-root, .app-shell, .app-shell--home, .home-page, .home-page__body, .home-page__panel, .home-v06, .home-v06__frame-wrap) {
  background-color: var(--mf-color-background-canvas);
}
html[data-theme="dark"] .home-v06.is-settings-open { background: var(--mf-color-background-canvas); }
html[data-theme="dark"] .home66 { background: radial-gradient(circle at 80% 12%, rgba(49,135,255,.12), transparent 34%), var(--mf-color-background-canvas); color: var(--mf-color-text-primary); }
html[data-theme="dark"] .home66-hero p,
html[data-theme="dark"] .home66-expert-desc { color: var(--mf-color-text-tertiary); }
html[data-theme="dark"] .home66-expert { background: color-mix(in srgb, var(--mf-color-background-surface) 94%, #1b2d45); border-color: var(--mf-color-border-default); }
html[data-theme="dark"] .home66-expert strong { color: var(--mf-color-text-primary); }

/* Elevation: floating layers sit one step above the container and gain a hairline. */
html[data-theme="dark"] .mfd-settings-window {
  background: var(--mf-color-background-surface);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 64px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] .mfd-settings-backdrop { background: rgba(0, 0, 0, 0.6); }

/* The v0.9.7 mascot (also the home page of v0.9.9) is a transparent cut-out in both themes, so it no longer needs the multiply blend
   that hid the white ground of the original artwork. */
html:is([data-edition="v097"], [data-edition="v099"], [data-edition="v08"]) .home66-mascot img { mix-blend-mode: normal; }
html[data-theme="dark"] .home66-mascot-media { mix-blend-mode: normal !important; filter: drop-shadow(0 10px 20px rgba(49,135,255,.24)); }
/* Without a white ground the two layers must not leave a seam: the hand layer follows the head's outline
   instead of a rectangle, and the body's cut-out is 0.3% smaller so both layers overlap at rest. */
html:is([data-edition="v097"], [data-edition="v099"], [data-edition="v08"]) .home66-mascot-hand { clip-path: polygon(0 43%, 24.8% 43%, 25.6% 45.5%, 26.6% 47.5%, 27.6% 49.5%, 28.6% 51.5%, 30.3% 53.5%, 33% 55.6%, 33% 61%, 0 61%); }
html:is([data-edition="v097"], [data-edition="v099"], [data-edition="v08"]) .home66-mascot-body { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 60.7%, 32.7% 60.7%, 32.7% 55.9%, 30% 53.9%, 28.3% 51.9%, 27.3% 49.9%, 26.3% 47.9%, 25.3% 45.9%, 24.5% 43.3%, 0 43.3%); }

/* Icons delivered as dark-ink image files (not currentColor) are inverted as a whole. */
html[data-theme="dark"] :is(.nav-item__icon img, .mfd-prefnav-glyph, [data-theme-icon="ink"]) {
  filter: invert(0.88) hue-rotate(180deg);
}

/* GEO charts: data marks keep their hue in both themes; only the grid and the point centre follow the surface. */
html[data-theme="dark"] :is(.geo-root, .geo-card-content, .geo-dialog-host) {
  --geo-mark-own: #3187ff; --geo-mark-r1: #faad14; --geo-mark-r2: #8a8984; --geo-mark-idle: #64635f;
  --geo-mark-ok: #a0d911; --geo-mark-watch: #fa9a14; --geo-mark-act: #ff4d4f;
  --geo-grid-line: #2f2e2a; --geo-point-bg: #1d1c1a;
}
/* Card protocol (card-spec.js): the waiting amber on a progress bar or a log dot is a solid status mark,
   not a tinted surface, so it keeps its value in dark (specification §3.4, principle 6). The generator
   reads a bare amber background as a light tint and would turn it into a dark brown that disappears. */
html[data-theme="dark"] .mfd-acard-body:is(.is-waiting, .is-blocked, .is-paused) .mfd-acard-bar > i,
html[data-theme="dark"] .mfd-acard-log > div:is(.is-blocked, .is-waiting, .is-paused) > i { background: #faad14; }
/* GEO overlays sit one step above the container, like the settings window. */
html[data-theme="dark"] :is(.geo-drawer, .geo-dialog, .geo-menu) { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 64px rgba(0, 0, 0, 0.6); }
html[data-theme="dark"] :is(.geo-drawer-backdrop, .geo-dialog-backdrop) { background: rgba(0, 0, 0, 0.6); }

/* ---- 3. Personal centre → 外观设置 --------------------------------------- */
.is-v097-appearance .mfd-settings-nav nav button[data-settings-tab="appearance"] svg { flex: none; }
.v097-appearance { max-width: 680px; margin: 0 auto; padding: 20px; border-radius: 12px; background: var(--mf-color-background-subtle); }
.v097-appearance > h3 { margin: 0 0 12px; font-size: 14px; line-height: 22px; font-weight: 500; color: var(--mf-color-text-primary); }
.v097-appearance-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.v097-appearance-option {
  position: relative; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 12px; min-width: 0; height: auto; padding: 12px;
  border: 1px solid var(--mf-color-border-default); border-radius: 8px; background: var(--mf-color-surface-default);
  color: var(--mf-color-text-primary); font: inherit; text-align: left; cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}
.v097-appearance-option:hover { border-color: var(--mf-color-border-strong); }
.v097-appearance-option:active { background: var(--mf-color-surface-secondary); }
.v097-appearance-option.is-on { border-color: var(--mf-color-action-primary); box-shadow: 0 0 0 1px var(--mf-color-action-primary); }
.v097-appearance-option:focus-visible { outline: 2px solid var(--mf-color-action-brand); outline-offset: 2px; }
.v097-appearance-copy { display: grid; gap: 2px; min-width: 0; padding-right: 24px; }
.v097-appearance-copy b { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; font-weight: 500; }
.v097-appearance-copy b svg { flex: none; color: var(--mf-color-icon-primary); }
.v097-appearance-copy small { font-size: 12px; line-height: 18px; color: var(--mf-color-text-tertiary); }
.v097-appearance-check {
  position: absolute; right: 12px; bottom: 14px; width: 16px; height: 16px; box-sizing: border-box;
  border: 1px solid var(--mf-color-border-default); border-radius: 50%; background: var(--mf-color-surface-default);
}
.v097-appearance-option.is-on .v097-appearance-check { border: 5px solid var(--mf-color-action-primary); }

/* Miniature windows use fixed palettes: they show a theme, they do not follow it. */
.v097-appearance-preview { display: flex; align-self: stretch; height: 84px; overflow: hidden; border: 1px solid var(--mf-color-border-subtle); border-radius: 6px; }
.v097-appearance-shot { flex: 1; display: flex; gap: 6px; min-width: 0; padding: 8px; background: var(--shot-canvas); }
.v097-appearance-shot[data-tone="light"] { --shot-canvas: #f5f5f5; --shot-surface: #ffffff; --shot-line: #d9d9d9; --shot-ink: #34322d; }
.v097-appearance-shot[data-tone="dark"] { --shot-canvas: #141413; --shot-surface: #1d1c1a; --shot-line: #3e3e3a; --shot-ink: #eceae4; }
.v097-appearance-shot > i { flex: none; width: 22%; max-width: 28px; border-radius: 3px; background: var(--shot-surface); box-shadow: inset 0 0 0 1px var(--shot-line); }
.v097-appearance-shot > b { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 8px 7px; border-radius: 3px; background: var(--shot-surface); box-shadow: inset 0 0 0 1px var(--shot-line); }
.v097-appearance-shot em { display: block; height: 4px; border-radius: 2px; background: var(--shot-line); }
.v097-appearance-shot em:first-child { width: 46%; background: var(--shot-ink); }
.v097-appearance-shot em:last-child { width: 68%; }
.v097-appearance-preview[data-preview="system"] .v097-appearance-shot[data-tone="light"] > i { display: none; }
.v097-appearance-preview[data-preview="system"] .v097-appearance-shot[data-tone="dark"] > i { display: none; }

.v097-appearance-status { margin: 16px 0 0; font-size: 13px; line-height: 20px; color: var(--mf-color-text-secondary); }
.v097-appearance-status[data-failed="1"] { color: #cf1322; }
html[data-theme="dark"] .v097-appearance-status[data-failed="1"] { color: #ff7d74; }
.v097-appearance-notes { display: grid; gap: 0; margin: 16px 0 0; padding: 4px 16px; border-radius: 8px; background: var(--mf-color-surface-default); }
.v097-appearance-notes > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--mf-color-border-subtle); }
.v097-appearance-notes > div:first-child { border-top: 0; }
.v097-appearance-notes dt { font-size: 13px; line-height: 20px; color: var(--mf-color-text-tertiary); }
.v097-appearance-notes dd { margin: 0; font-size: 13px; line-height: 20px; color: var(--mf-color-text-secondary); }
@media (max-width: 720px) {
  .v097-appearance { padding: 16px; }
  .v097-appearance-options { grid-template-columns: minmax(0, 1fr); }
  .v097-appearance-option { flex-direction: row; align-items: center; }
  .v097-appearance-preview { flex: none; width: 112px; height: 64px; }
}
@media (prefers-reduced-motion: reduce) { .v097-appearance-option { transition: none; } }

/* Original Figma plus is white; the dark primary action has a light fill. */
html[data-theme="dark"] .product-library-page--v095 .collect-products-button--tabbar>img{filter:invert(1)}
