/* ==========================================================================
   色谱台 · CHROMA BENCH
   所有界面颜色都来自 Material 3 动态取色（见 js/theme.js）。
   这里只定义结构、节奏与排版，不写死任何一个颜色值。
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. 基础
   -------------------------------------------------------------------------- */

:root {
  --rail-w: 88px;
  --pad-x: 40px;
  --topbar-h: 76px;

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-2xl: 28px;

  --hairline: 1px solid var(--md-sys-color-outline-variant);
  --hairline-soft: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 55%, transparent);

  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-decel: cubic-bezier(0, 0, 0, 1);
  --ease-accel: cubic-bezier(0.3, 0, 1, 1);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);

  --surface-0: var(--md-sys-color-surface);
  --surface-1: var(--md-sys-color-surface-container-low);
  --surface-2: var(--md-sys-color-surface-container);
  --surface-3: var(--md-sys-color-surface-container-high);
  --surface-4: var(--md-sys-color-surface-container-highest);
  --surface-lowest: var(--md-sys-color-surface-container-lowest);

  --on-surface: var(--md-sys-color-on-surface);
  --on-surface-var: var(--md-sys-color-on-surface-variant);
  --outline: var(--md-sys-color-outline);
  --outline-var: var(--md-sys-color-outline-variant);
  --primary: var(--md-sys-color-primary);
  --on-primary: var(--md-sys-color-on-primary);
  --primary-container: var(--md-sys-color-primary-container);
  --on-primary-container: var(--md-sys-color-on-primary-container);
  --secondary-container: var(--md-sys-color-secondary-container);
  --on-secondary-container: var(--md-sys-color-on-secondary-container);
  --tertiary-container: var(--md-sys-color-tertiary-container);
  --on-tertiary-container: var(--md-sys-color-on-tertiary-container);
  --error: var(--md-sys-color-error);
  --on-error: var(--md-sys-color-on-error);
  --error-container: var(--md-sys-color-error-container);
  --on-error-container: var(--md-sys-color-on-error-container);
  --inverse-surface: var(--md-sys-color-inverse-surface);
  --inverse-on-surface: var(--md-sys-color-inverse-on-surface);
  --inverse-primary: var(--md-sys-color-inverse-primary);
  --shadow-1: var(--md-sys-elevation-shadow-1);
  --shadow-2: var(--md-sys-elevation-shadow-2);
  --shadow-3: var(--md-sys-elevation-shadow-3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--surface-0);
  color: var(--on-surface);
  font-family: var(--md-ref-typeface-plain);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-dragging,
body.is-resizing {
  cursor: grabbing;
}

::selection {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
}

img,
canvas,
svg {
  display: block;
  max-width: 100%;
}

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

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

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

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--outline) 55%, transparent);
  border-radius: 999px;
  border: 3px solid var(--surface-0);
}

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

.material-symbols-outlined {
  font-size: 24px;
  line-height: 1;
  flex: none;
  user-select: none;
}

/* 排版工具 --------------------------------------------------------------- */

.t-display {
  font-family: var(--md-ref-typeface-brand);
  font-size: 2.25rem;
  line-height: 2.75rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.t-headline {
  font-family: var(--md-ref-typeface-brand);
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.t-title-lg {
  font-family: var(--md-ref-typeface-brand);
  font-size: 1.375rem;
  line-height: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.t-title {
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.t-body {
  font-size: 0.9375rem;
  line-height: 1.7;
}

.t-body-sm {
  font-size: 0.875rem;
  line-height: 1.65;
}

.t-label {
  font-size: 0.8125rem;
  line-height: 1.5;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.t-muted {
  color: var(--on-surface-var);
}

.t-mono {
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", "Cascadia Mono",
    "Roboto Mono", "Noto Sans Mono CJK SC", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.t-num {
  font-variant-numeric: tabular-nums;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--inverse-surface);
  color: var(--inverse-on-surface);
  font-size: 14px;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 160ms var(--ease-standard);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline-color: var(--inverse-primary);
}

.is-hidden {
  display: none !important;
}

/* --------------------------------------------------------------------------
   1. 应用骨架
   -------------------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100dvh;
}

.shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
}

/* 导航栏（navigation rail） ------------------------------------------------- */

.rail {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100dvh;
  padding: 18px 0 14px;
  background: var(--surface-0);
  border-right: var(--hairline-soft);
}

.rail__brand {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: var(--r-md);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: conic-gradient(
    from 200deg,
    var(--primary),
    var(--md-sys-color-tertiary),
    var(--md-sys-color-secondary),
    var(--primary)
  );
  transition: transform 500ms var(--ease-emphasized);
}

.brand-mark::after {
  content: '';
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: var(--surface);
}

.brand-mark i {
  display: none;
}

.rail__brand:hover .brand-mark {
  transform: rotate(80deg);
}

.brand-mark--sm {
  width: 38px;
  height: 38px;
  flex: none;
}

.brand-mark--sm::after {
  inset: 10px;
}

.rail__items {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  flex: 1;
}

.rail__foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  padding-top: 10px;
  margin-top: 8px;
  border-top: var(--hairline-soft);
}

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  padding: 5px 0;
  color: var(--on-surface-var);
  text-decoration: none;
  transition: color 180ms var(--ease-standard);
}

.rail-item__indicator {
  display: grid;
  place-items: center;
  width: 56px;
  height: 32px;
  border-radius: 999px;
  transition: background-color 200ms var(--ease-standard),
    color 200ms var(--ease-standard);
}

.rail-item__label {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.rail-item:hover {
  color: var(--on-surface);
}

.rail-item:hover .rail-item__indicator {
  background: color-mix(in srgb, var(--on-surface) 8%, transparent);
}

.rail-item:active .rail-item__indicator {
  transform: scale(0.96);
}

.rail-item.is-active {
  color: var(--on-surface);
}

.rail-item.is-active .rail-item__indicator {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.rail-item.is-active .material-symbols-outlined {
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}

/* 顶栏 ------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--topbar-h);
  padding: 0 var(--pad-x);
  background: color-mix(in srgb, var(--surface-0) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border-bottom: var(--hairline-soft);
}

.topbar__lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar__menu {
  display: none;
}

.topbar__titles {
  min-width: 0;
}

.topbar__title {
  font-family: var(--md-ref-typeface-brand);
  font-size: 1.375rem;
  line-height: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.topbar__sub {
  overflow: hidden;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* 收藏页自己有「保存当前方案」，顶栏不再重复同一个保存动作 */
body[data-view="library"] #btn-save {
  display: none;
}

.seed-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 9px;
  border: var(--hairline);
  border-radius: 999px;
  color: var(--on-surface-var);
  transition: background-color 180ms var(--ease-standard),
    border-color 180ms var(--ease-standard);
}

.seed-chip:hover {
  background: var(--surface-1);
  border-color: var(--outline);
}

.seed-chip__dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--seed-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 14%, transparent);
}

.seed-chip__hex {
  font-family: ui-monospace, "Cascadia Mono", "Roboto Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* 内容区 ------------------------------------------------------------------ */

.content {
  flex: 1;
  padding: 24px var(--pad-x) 72px;
}

.view-root {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  outline: none;
}

.view {
  animation: view-in 380ms var(--ease-decel) both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 18px;
}

.section-title {
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.section-hint {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.section-head__left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.section-head__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   2. 通用控件
   -------------------------------------------------------------------------- */

/* 按钮 ------------------------------------------------------------------- */

.btn {
  --btn-h: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: var(--btn-h);
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 180ms var(--ease-standard),
    color 180ms var(--ease-standard),
    border-color 180ms var(--ease-standard),
    box-shadow 180ms var(--ease-standard),
    transform 120ms var(--ease-standard);
}

.btn .material-symbols-outlined {
  font-size: 18px;
}

.btn:active {
  transform: scale(0.965);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.btn--filled {
  background: var(--primary);
  color: var(--on-primary);
}

.btn--filled:hover {
  background: color-mix(in srgb, var(--primary) 90%, var(--on-primary));
  box-shadow: var(--shadow-1);
}

.btn--tonal {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.btn--tonal:hover {
  background: color-mix(
    in srgb,
    var(--secondary-container) 88%,
    var(--on-secondary-container)
  );
}

.btn--outlined {
  border-color: var(--outline);
  color: var(--primary);
  background: transparent;
}

.btn--outlined:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.btn--text {
  padding: 0 14px;
  color: var(--primary);
}

.btn--text:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.btn--danger {
  background: var(--error);
  color: var(--on-error);
}

.btn--danger:hover {
  background: color-mix(in srgb, var(--error) 90%, var(--on-error));
}

.btn--danger-text {
  background: transparent;
  color: var(--error);
}

.btn--danger-text:hover {
  background: color-mix(in srgb, var(--error) 9%, transparent);
}

.btn--block {
  width: 100%;
}

.btn--sm {
  --btn-h: 34px;
  padding: 0 16px;
  font-size: 13px;
}

/* 图标按钮 --------------------------------------------------------------- */

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 999px;
  color: var(--on-surface-var);
  transition: background-color 180ms var(--ease-standard),
    color 180ms var(--ease-standard),
    transform 120ms var(--ease-standard);
}

.icon-btn .material-symbols-outlined {
  font-size: 22px;
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--on-surface) 8%, transparent);
  color: var(--on-surface);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn--sm {
  width: 32px;
  height: 32px;
}

.icon-btn--sm .material-symbols-outlined {
  font-size: 19px;
}

.icon-btn--tonal {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.icon-btn--error {
  color: var(--error);
}

.icon-btn--error:hover {
  background: color-mix(in srgb, var(--error) 10%, transparent);
  color: var(--error);
}

/* 分段控件 --------------------------------------------------------------- */

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 3px;
  border: var(--hairline);
  border-radius: 999px;
  background: transparent;
}

.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 180ms var(--ease-standard),
    color 180ms var(--ease-standard);
}

.segmented button .material-symbols-outlined {
  font-size: 17px;
}

.segmented button:hover {
  background: color-mix(in srgb, var(--on-surface) 7%, transparent);
  color: var(--on-surface);
}

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

.segmented--compact {
  height: 36px;
}

.segmented--compact button {
  height: 28px;
  padding: 0 12px;
}

.segmented--full {
  display: flex;
  width: 100%;
}

.segmented--full button {
  flex: 1;
}

/* 小标签 ---------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1;
  font-weight: 500;
  white-space: nowrap;
}

.pill--quiet {
  background: transparent;
  padding: 0;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
}

.save-state .material-symbols-outlined {
  font-size: 16px;
}

.save-state.is-saving .material-symbols-outlined {
  animation: spin 1s linear infinite;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-size: 13px;
  line-height: 1;
  font-weight: 500;
  white-space: nowrap;
}

.badge--error {
  background: var(--error-container);
  color: var(--on-error-container);
}

.badge--neutral {
  background: var(--surface-3);
  color: var(--on-surface-var);
}

/* 表单 ------------------------------------------------------------------ */

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

.field__label {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.field__optional {
  color: var(--on-surface-var);
  font-weight: 400;
}

.field__row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.field__input {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-sm);
  background: var(--surface-lowest);
  color: var(--on-surface);
  font-size: 15px;
  line-height: 1.5;
  transition: background-color 180ms var(--ease-standard),
    border-color 180ms var(--ease-standard),
    box-shadow 180ms var(--ease-standard);
}

.field__input::placeholder {
  color: var(--on-surface-var);
  opacity: 1;
}

.field__input:hover {
  border-color: var(--outline);
}

.field__input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface-lowest);
  box-shadow: 0 0 0 1px var(--primary);
}

.field__input--mono {
  font-family: ui-monospace, "Cascadia Mono", "Roboto Mono", monospace;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field__input.is-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.field__error {
  color: var(--error);
  font-size: 13px;
  line-height: 1.5;
}

.field__swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border: var(--hairline);
  border-radius: var(--r-sm);
  color: var(--on-surface-var);
  cursor: pointer;
  overflow: hidden;
}

.field__swatch:hover {
  background: var(--surface-1);
}

.field__swatch input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.select-wrap .material-symbols-outlined {
  position: absolute;
  right: 12px;
  color: var(--on-surface-var);
  font-size: 20px;
  pointer-events: none;
}

.select {
  height: 44px;
  width: 100%;
  min-width: 180px;
  padding: 0 40px 0 15px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--on-surface);
  font-size: 15px;
  line-height: 1.4;
  appearance: none;
  cursor: pointer;
  transition: background-color 180ms var(--ease-standard),
    border-color 180ms var(--ease-standard);
}

.select:hover {
  background: var(--surface-4);
}

.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* 开关（自绘，用于设置以外的紧凑位置） ---------------------------------- */

.switch {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 52px;
  height: 32px;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch__track {
  width: 100%;
  height: 100%;
  border: 2px solid var(--outline);
  border-radius: 999px;
  background: var(--surface-4);
  transition: background-color 200ms var(--ease-standard),
    border-color 200ms var(--ease-standard);
}

.switch__track::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  margin: 6px;
  border-radius: 50%;
  background: var(--outline);
  transition: transform 200ms var(--ease-emphasized),
    background-color 200ms var(--ease-standard),
    width 200ms var(--ease-emphasized),
    height 200ms var(--ease-emphasized);
}

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

.switch input:checked + .switch__track::after {
  background: var(--on-primary);
  transform: translateX(20px);
  width: 24px;
  height: 24px;
  margin: 2px;
}

.switch input:focus-visible + .switch__track {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* 图片 / 内容滚动容器 ---------------------------------------------------- */

.scroll-x {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

/* --------------------------------------------------------------------------
   3. 反馈层：toast / menu / dialog / drawer
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 6px 6px 6px 18px;
  border-radius: var(--r-sm);
  background: var(--inverse-surface);
  color: var(--inverse-on-surface);
  box-shadow: var(--shadow-3);
  font-size: 14px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 220ms var(--ease-standard),
    transform 300ms var(--ease-emphasized);
}

.toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast__text {
  padding: 6px 0;
}

.toast__action {
  flex: none;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--inverse-primary);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 160ms var(--ease-standard);
}

.toast__action:hover {
  background: color-mix(in srgb, var(--inverse-on-surface) 10%, transparent);
}

/* 菜单 ------------------------------------------------------------------- */

.menu {
  position: fixed;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 190px;
  max-width: 260px;
  padding: 7px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
  animation: menu-in 160ms var(--ease-decel) both;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--r-xs);
  color: var(--on-surface);
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  white-space: nowrap;
  transition: background-color 140ms var(--ease-standard);
}

.menu__item .material-symbols-outlined {
  font-size: 20px;
  color: var(--on-surface-var);
}

.menu__item:hover {
  background: color-mix(in srgb, var(--on-surface) 9%, transparent);
}

.menu__item--danger {
  color: var(--error);
}

.menu__item--danger .material-symbols-outlined {
  color: var(--error);
}

.menu__item--danger:hover {
  background: color-mix(in srgb, var(--error) 10%, transparent);
}

.menu__sep {
  height: 1px;
  margin: 5px 8px;
  background: var(--outline-variant);
}

/* 对话框 ----------------------------------------------------------------- */

.dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 24px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: var(--r-2xl);
  background: var(--md-sys-color-surface-container-high);
  color: var(--on-surface);
  box-shadow: 0 20px 60px color-mix(in srgb, #000 26%, transparent);
}

.dialog[open] {
  animation: dialog-in 300ms var(--ease-emphasized) both;
}

.dialog::backdrop {
  background: color-mix(in srgb, #000 38%, transparent);
  animation: backdrop-in 260ms ease both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dialog__title {
  font-family: var(--md-ref-typeface-brand);
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.dialog__desc {
  margin-bottom: 18px;
  color: var(--on-surface-var);
  font-size: 14px;
  line-height: 1.65;
}

.dialog__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog__form .dialog__head {
  margin-bottom: 0;
}

.dialog__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.dialog__foot--quiet {
  justify-content: space-between;
}

.dialog--confirm {
  width: min(440px, calc(100vw - 32px));
}

.dialog--settings {
  width: min(680px, calc(100vw - 32px));
}

.dialog--help {
  width: min(640px, calc(100vw - 32px));
}

.dialog--prompt {
  width: min(460px, calc(100vw - 32px));
}

/* 设置 ------------------------------------------------------------------- */

.settings {
  display: flex;
  flex-direction: column;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0;
  border-bottom: var(--hairline);
}

.setting:first-child {
  padding-top: 4px;
}

.setting:last-child {
  border-bottom: 0;
}

.setting__text {
  min-width: 0;
}

.setting__text h3 {
  margin-bottom: 3px;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
}

.setting__text p {
  max-width: 380px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

md-switch {
  flex: none;
}

.about {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: var(--hairline);
}

.about__text strong {
  display: block;
  font-size: 15px;
  font-weight: 500;
}

.about__text strong span {
  margin-left: 6px;
  color: var(--on-surface-var);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.about__text p {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

/* 帮助 ------------------------------------------------------------------- */

.help {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.help h3 {
  margin-bottom: 6px;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
}

.help p {
  color: var(--on-surface-var);
  font-size: 14px;
  line-height: 1.7;
}

.shortcuts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 24px;
  margin: 0;
}

.shortcuts > div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: var(--hairline-soft);
}

.shortcuts dt {
  display: flex;
  align-items: center;
  gap: 3px;
}

.shortcuts dd {
  margin: 0;
  color: var(--on-surface-var);
  font-size: 13px;
  white-space: nowrap;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--outline);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--on-surface-var);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
}

.help__note {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

/* 抽屉（移动端导航） ----------------------------------------------------- */

.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(330px, 86vw);
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 20px 14px;
  border: 0;
  border-radius: 0 var(--r-xl) var(--r-xl) 0;
  background: var(--surface-1);
  color: var(--on-surface);
  box-shadow: var(--shadow-3);
  display: none;
  flex-direction: column;
}

.drawer[open] {
  display: flex;
  animation: drawer-in 300ms var(--ease-emphasized) both;
}

.drawer::backdrop {
  background: color-mix(in srgb, #000 36%, transparent);
}

@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px 18px;
}

.drawer__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.drawer__brand-text strong {
  display: block;
  font-size: 16px;
  line-height: 1.4;
  font-weight: 500;
}

.drawer__brand-text span {
  color: var(--on-surface-var);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.drawer__items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 52px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--on-surface-var);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  text-align: left;
  transition: background-color 180ms var(--ease-standard),
    color 180ms var(--ease-standard);
}

.drawer-item .material-symbols-outlined {
  font-size: 23px;
}

.drawer-item:hover {
  background: color-mix(in srgb, var(--on-surface) 7%, transparent);
  color: var(--on-surface);
}

.drawer-item.is-active {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.drawer-item.is-active .material-symbols-outlined {
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}

.drawer__foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
  border-top: var(--hairline);
}

.drawer__foot-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--on-surface-var);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.drawer__foot-btn .material-symbols-outlined {
  font-size: 22px;
}

.drawer__foot-btn:hover {
  background: color-mix(in srgb, var(--on-surface) 7%, transparent);
  color: var(--on-surface);
}

/* --------------------------------------------------------------------------
   4. 工作台
   -------------------------------------------------------------------------- */

/* 源色条 ----------------------------------------------------------------- */

.source-strip {
  display: flex;
  align-items: center;
  gap: 32px;
  padding-bottom: 26px;
  border-bottom: var(--hairline);
}

.source {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: none;
}

.source__orb-wrap {
  position: relative;
  width: 108px;
  height: 108px;
  flex: none;
}

.source__hue {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--hue-ring, conic-gradient(from -90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00));
  -webkit-mask: radial-gradient(
    farthest-side,
    transparent calc(100% - 7px),
    #000 calc(100% - 6px)
  );
  mask: radial-gradient(
    farthest-side,
    transparent calc(100% - 7px),
    #000 calc(100% - 6px)
  );
  opacity: 0.95;
}

.source__marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--seed-color, var(--primary));
  border: 2px solid var(--surface-0);
  box-shadow: 0 1px 4px color-mix(in srgb, #000 35%, transparent);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 90ms linear, top 90ms linear;
}

.source__orb {
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background: var(--seed-color, var(--primary));
  cursor: grab;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent),
    var(--shadow-1);
  touch-action: none;
  transition: transform 160ms var(--ease-standard),
    box-shadow 160ms var(--ease-standard);
}

.source__orb:hover {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent),
    var(--shadow-2);
}

.source__orb:active,
.source__orb.is-dragging {
  cursor: grabbing;
  transform: scale(0.97);
}

.source__orb:focus-visible {
  outline: 3px solid var(--on-surface);
  outline-offset: 4px;
}

.source__orb.is-highlight {
  animation: orb-ping 900ms var(--ease-standard) both;
}

@keyframes orb-ping {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 55%, transparent),
      inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent);
  }
  70% {
    box-shadow: 0 0 0 14px transparent,
      inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 transparent,
      inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent);
  }
}

.source__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.source__eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.source__hex-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: -6px;
}

.source__hex-input {
  width: 8.4ch;
  height: 36px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--on-surface);
  font-family: ui-monospace, "Cascadia Mono", "Roboto Mono", monospace;
  font-size: 1.25rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: background-color 160ms var(--ease-standard),
    box-shadow 160ms var(--ease-standard);
}

.source__hex-input:hover {
  background: color-mix(in srgb, var(--on-surface) 6%, transparent);
}

.source__hex-input:focus {
  outline: none;
  background: var(--surface-1);
  box-shadow: 0 0 0 2px var(--primary);
}

.source__hex-input.is-invalid {
  box-shadow: 0 0 0 2px var(--error);
}

.source__meta-actions {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: -4px;
}

.source__meta-actions .icon-btn {
  width: 32px;
  height: 32px;
}

.source__meta-actions .material-symbols-outlined {
  font-size: 18px;
}

.source__hct {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-family: ui-monospace, "Cascadia Mono", "Roboto Mono", monospace;
  letter-spacing: 0.01em;
}

.source__hint {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.9;
}

.role-strip {
  flex: 1;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.role-strip__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.role-strip__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-chip {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  width: 66px;
  text-align: left;
}

.role-chip__fill {
  position: relative;
  height: 42px;
  border-radius: var(--r-sm);
  background: var(--chip-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent);
  transition: transform 180ms var(--ease-standard),
    box-shadow 180ms var(--ease-standard);
}

.role-chip:hover .role-chip__fill {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent),
    var(--shadow-1);
}

.role-chip__label {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-chip.is-refreshing .role-chip__fill {
  animation: role-pop 320ms var(--ease-emphasized) both;
  animation-delay: var(--role-delay, 0ms);
}

@keyframes role-pop {
  from {
    transform: scale(0.88);
    opacity: 0.4;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.source-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex: none;
  width: 158px;
}

.source-actions .btn {
  justify-content: flex-start;
}

/* 方案头部 --------------------------------------------------------------- */

.palette-block {
  margin-top: 30px;
}

.palette-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
  margin-bottom: 16px;
}

.palette-ident {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
}

.palette-name {
  width: auto;
  min-width: 2ch;
  max-width: min(420px, 70vw);
  field-sizing: content;
  padding: 3px 8px;
  margin-left: -8px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--on-surface);
  font-family: var(--md-ref-typeface-brand);
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background-color 160ms var(--ease-standard),
    box-shadow 160ms var(--ease-standard);
}

.palette-name:hover {
  background: color-mix(in srgb, var(--on-surface) 6%, transparent);
}

.palette-name:focus {
  outline: none;
  background: var(--surface-1);
  box-shadow: 0 0 0 2px var(--primary);
}

.palette-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.palette-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* 色板 ------------------------------------------------------------------- */

.deck {
  display: grid;
  grid-template-columns: repeat(var(--deck-count, 8), minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.swatch__color {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(320px, 40vh, 440px);
  border: 0;
  border-radius: var(--r-lg);
  background-color: var(--swatch-color, var(--primary));
  cursor: pointer;
  isolation: isolate;
  transition: transform 220ms var(--ease-standard),
    box-shadow 220ms var(--ease-standard),
    outline-color 160ms var(--ease-standard),
    background-color 180ms var(--ease-standard);
}

.swatch__color::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 7%, transparent);
  pointer-events: none;
}

.swatch__color:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-2);
}

.swatch__color:active {
  transform: translateY(-1px);
}

.swatch__color:focus-visible {
  outline: 3px solid var(--on-surface);
  outline-offset: 3px;
}

.swatch.is-selected .swatch__color {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.swatch__check {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-1);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 180ms var(--ease-standard),
    transform 220ms var(--ease-emphasized);
  pointer-events: none;
}

.swatch__check .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 20;
}

.swatch.is-selected .swatch__check {
  opacity: 1;
  transform: scale(1);
}

.swatch__more {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface-0) 88%, transparent);
  color: var(--on-surface);
  box-shadow: var(--shadow-1);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 160ms var(--ease-standard),
    transform 160ms var(--ease-standard),
    background-color 160ms var(--ease-standard);
}

.swatch__more .material-symbols-outlined {
  font-size: 20px;
}

.swatch:hover .swatch__more,
.swatch:focus-within .swatch__more,
.swatch.is-selected .swatch__more {
  opacity: 1;
  transform: none;
}

.swatch__more:hover {
  background: var(--surface-0);
}

.swatch__meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 3px 0;
  min-width: 0;
}

.swatch__names {
  min-width: 0;
}

.swatch__name {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.swatch__hex {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
  font-family: ui-monospace, "Cascadia Mono", "Roboto Mono", monospace;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.swatch__drag {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 6px;
  color: var(--on-surface-var);
  cursor: grab;
  opacity: 0;
  transition: opacity 160ms var(--ease-standard),
    background-color 160ms var(--ease-standard);
}

.swatch__drag .material-symbols-outlined {
  font-size: 17px;
}

.swatch:hover .swatch__drag,
.swatch:focus-within .swatch__drag {
  opacity: 1;
}

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

.swatch.is-dragging {
  opacity: 0.35;
}

.swatch.is-drop-target .swatch__color {
  outline: 2px dashed var(--primary);
  outline-offset: 4px;
}

.deck-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.deck-hint .material-symbols-outlined {
  font-size: 17px;
}

.deck-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 300px;
  padding: 40px;
  border: 1px dashed var(--outline);
  border-radius: var(--r-lg);
  color: var(--on-surface-var);
  text-align: center;
}

.deck-empty .material-symbols-outlined {
  font-size: 32px;
  color: var(--outline);
}

.deck-empty h3 {
  color: var(--on-surface);
  font-size: 17px;
  line-height: 1.5;
  font-weight: 500;
}

.deck-empty p {
  max-width: 42ch;
  font-size: 14px;
  line-height: 1.65;
}

/* 首次入场 --------------------------------------------------------------- */

.deck--enter .swatch {
  animation: swatch-in 340ms var(--ease-decel) both;
  animation-delay: min(calc(var(--i, 0) * 40ms), 400ms);
}

@keyframes swatch-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 检视区 ----------------------------------------------------------------- */

.inspect {
  margin-top: 34px;
  padding: 24px;
  border-radius: var(--r-xl);
  background: var(--surface-1);
}

.inspect__top {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 290px;
  gap: 32px;
}

.inspect__ident {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inspect__chip {
  position: relative;
  height: 132px;
  border-radius: var(--r-md);
  background: var(--swatch-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent);
}

.inspect__chip::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    120% 120% at 18% 12%,
    color-mix(in srgb, #fff 14%, transparent),
    transparent 60%
  );
  pointer-events: none;
}

.inspect__name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.inspect__name h3 {
  overflow: hidden;
  font-size: 1.25rem;
  line-height: 1.6rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.inspect__name .t-mono {
  color: var(--on-surface-var);
  font-size: 13px;
  text-transform: uppercase;
  white-space: nowrap;
}

.inspect__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.inspect__actions .btn {
  --btn-h: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.inspect__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.inspect__label span {
  font-weight: 400;
}

.inspect__mid {
  min-width: 0;
}

.formats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
}

.format-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 39px;
  border-bottom: var(--hairline-soft);
  text-align: left;
  transition: background-color 160ms var(--ease-standard);
}

.format-row:hover {
  background: color-mix(in srgb, var(--on-surface) 5%, transparent);
}

.format-row__key {
  width: 46px;
  flex: none;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
}

.format-row__val {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
  font-family: ui-monospace, "Cascadia Mono", "Roboto Mono", monospace;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.format-row .material-symbols-outlined {
  font-size: 16px;
  color: var(--on-surface-var);
  opacity: 0;
  transition: opacity 160ms var(--ease-standard);
}

.format-row:hover .material-symbols-outlined {
  opacity: 1;
}

.inspect__facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-top: 16px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.inspect__fact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.inspect__fact .material-symbols-outlined {
  font-size: 16px;
}

.inspect__contrast {
  min-width: 0;
  padding-left: 28px;
  border-left: var(--hairline);
}

.contrast-mini {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contrast-mini__row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  margin: 0 -8px;
  border-radius: var(--r-xs);
  text-align: left;
  transition: background-color 160ms var(--ease-standard);
}

.contrast-mini__row:hover {
  background: color-mix(in srgb, var(--on-surface) 6%, transparent);
}

.contrast-mini__plate {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 12px;
  font-size: 24px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.contrast-mini__plate--dark {
  background: #111;
  color: #fff;
}

.contrast-mini__plate--light {
  background: #fff;
  color: #111;
  box-shadow: inset 0 0 0 1px #0002;
}

.contrast-mini__body {
  flex: 1;
  min-width: 0;
}

.contrast-mini__title {
  font-size: 13px;
  line-height: 1.5;
}

.contrast-mini__ratio {
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--on-surface-var);
}

.contrast-mini__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
}

.contrast-mini__link .material-symbols-outlined {
  font-size: 17px;
}

/* 色阶 ------------------------------------------------------------------- */

.ramp {
  margin-top: 22px;
  padding-top: 20px;
  border-top: var(--hairline);
}

.ramp__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.ramp__title {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.ramp__hint {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
}

.ramp__cells {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 8px;
}

.ramp__cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ramp__fill {
  height: 56px;
  border-radius: var(--r-xs);
  background: var(--tone-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 7%, transparent);
  transition: transform 170ms var(--ease-standard),
    box-shadow 170ms var(--ease-standard);
}

.ramp__cell:hover .ramp__fill {
  transform: translateY(-3px);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 7%, transparent),
    var(--shadow-1);
}

.ramp__cell:focus-visible {
  outline: none;
}

.ramp__cell:focus-visible .ramp__fill {
  outline: 3px solid var(--on-surface);
  outline-offset: 2px;
}

.ramp__tone {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 精选 ------------------------------------------------------------------- */

.presets {
  margin-top: 44px;
}

.presets__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.presets__link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--primary);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
  text-decoration: none;
}

.presets__link .material-symbols-outlined {
  font-size: 18px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.preset-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  text-align: left;
}

.preset-card__strip {
  display: flex;
  gap: 2px;
  height: 92px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-3);
  transition: transform 220ms var(--ease-standard),
    box-shadow 220ms var(--ease-standard);
}

.preset-card:hover .preset-card__strip {
  transform: translateY(-4px);
  box-shadow: var(--shadow-2);
}

.preset-card__strip span {
  flex: 1;
  min-width: 0;
}

.preset-card__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 3px 0;
}

.preset-card__name {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.preset-card__sub {
  flex: none;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   5. 色轮
   -------------------------------------------------------------------------- */

.wheel-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 36px;
  align-items: start;
}

.wheel-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 4px;
}

.wheel {
  position: relative;
  width: min(640px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  touch-action: none;
  user-select: none;
}

.wheel:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 6px;
}

.wheel__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.wheel__lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.wheel__disc {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 76%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}

.tone-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.wheel__disc-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 74px;
  height: 74px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--seed-color, var(--primary));
  border: 3px solid var(--surface-0);
  box-shadow: var(--shadow-2);
  display: grid;
  place-items: center;
}

.wheel__pin {
  position: absolute;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid var(--surface-0);
  box-shadow: 0 1px 4px color-mix(in srgb, #000 32%, transparent);
  pointer-events: none;
  background: var(--pin-color, var(--primary));
}

.wheel__pin.is-base {
  width: 22px;
  height: 22px;
  border-width: 3px;
  box-shadow: 0 0 0 2px var(--on-surface), 0 2px 6px #0004;
}

.wheel__tone-marker {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--on-surface);
  border: 2px solid var(--surface-0);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.wheel__readout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.wheel__readout strong {
  color: var(--on-surface);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.wheel__readout .sep {
  width: 1px;
  height: 12px;
  background: var(--outline-variant);
}

.wheel-panel {
  padding: 24px;
  border-radius: var(--r-xl);
  background: var(--surface-1);
}

.wheel-panel__head {
  margin-bottom: 16px;
}

.wheel-panel__head h2 {
  margin-bottom: 4px;
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 500;
}

.wheel-panel__head p {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.harmony-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.rule-chip {
  height: 32px;
  padding: 0 12px;
  border: var(--hairline);
  border-radius: var(--r-xs);
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 170ms var(--ease-standard),
    color 170ms var(--ease-standard),
    border-color 170ms var(--ease-standard);
}

.rule-chip:hover {
  background: color-mix(in srgb, var(--on-surface) 7%, transparent);
  color: var(--on-surface);
}

.rule-chip.is-active {
  background: var(--secondary-container);
  border-color: transparent;
  color: var(--on-secondary-container);
}

.harmony-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -8px 16px;
}

.harmony-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 6px 8px;
  border-radius: var(--r-xs);
  transition: background-color 160ms var(--ease-standard);
}

.harmony-row:hover {
  background: color-mix(in srgb, var(--on-surface) 6%, transparent);
}

.harmony-row__swatch {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--r-xs);
  background: var(--h-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent);
}

.harmony-row__body {
  flex: 1;
  min-width: 0;
}

.harmony-row__name {
  font-size: 14px;
  line-height: 1.5;
}

.harmony-row__hex {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.harmony-row__actions {
  display: flex;
  gap: 2px;
  flex: none;
}

.harmony-row__actions .icon-btn {
  width: 32px;
  height: 32px;
}

.harmony-row__actions .material-symbols-outlined {
  font-size: 18px;
}

.wheel-panel__foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wheel-panel__note {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.wheel-panel__divider {
  height: 1px;
  margin: 22px 0 18px;
  background: var(--outline-variant);
}

.precise {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.precise__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.precise__head h3 {
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
}

.precise__head span {
  color: var(--on-surface-var);
  font-size: 13px;
}

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

.slider__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
}

.slider__value {
  color: var(--on-surface);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

input[type="range"].range {
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type="range"].range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--range-track, var(--surface-4));
}

input[type="range"].range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface-0);
  box-shadow: 0 1px 4px color-mix(in srgb, #000 30%, transparent);
  transition: transform 120ms var(--ease-standard);
}

input[type="range"].range:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

input[type="range"].range:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 4px;
  border-radius: 999px;
}

input[type="range"].range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--range-track, var(--surface-4));
}

input[type="range"].range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface-0);
}

/* --------------------------------------------------------------------------
   6. 系统
   -------------------------------------------------------------------------- */

.sys-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 20px 28px;
  padding-bottom: 22px;
  margin-bottom: 28px;
  border-bottom: var(--hairline);
}

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

.sys-control__label {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.sys-control--wide .select {
  min-width: 240px;
}

.sys-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding-bottom: 4px;
  color: var(--on-surface-var);
  font-size: 13px;
}

.sys-section {
  margin-bottom: 38px;
}

.sys-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 20px;
  margin-bottom: 14px;
}

.sys-section__head h2 {
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 500;
}

.sys-section__head p {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.tonal-block {
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.tonal-inner {
  min-width: 900px;
}

.tonal-scroll-hint {
  display: none;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
}

.tonal-scroll-hint .material-symbols-outlined {
  flex: none;
  font-size: 17px;
}

.tonal-head {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 6px;
}

.tonal-head__tones {
  display: grid;
  grid-template-columns: repeat(21, minmax(0, 1fr));
  gap: 3px;
}

.tonal-head__tones span {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.tonal-row {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 9px;
}

.tonal-label {
  min-width: 0;
  position: sticky;
  left: 0;
  z-index: 2;
  padding-right: 10px;
  background: var(--surface);
}

.tonal-label strong {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
}

.tonal-label span {
  display: block;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-family: ui-monospace, "Cascadia Mono", monospace;
}

.tonal-cells {
  display: grid;
  grid-template-columns: repeat(21, minmax(0, 1fr));
  gap: 3px;
}

.tonal-cell {
  position: relative;
  height: 42px;
  min-width: 0;
  border-radius: 5px;
  background: var(--tone-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 5%, transparent);
  transition: transform 150ms var(--ease-standard),
    box-shadow 150ms var(--ease-standard);
}

.tonal-cell:hover {
  z-index: 2;
  transform: translateY(-3px) scale(1.04);
  box-shadow: var(--shadow-1);
}

.tonal-cell.is-selected {
  outline: 2px solid var(--on-surface);
  outline-offset: 1px;
}

.tonal-cell:focus-visible {
  outline: 3px solid var(--on-surface);
  outline-offset: 2px;
}

.pairs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.pair {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  text-align: left;
}

.pair__block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  height: 78px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  background: var(--pair-bg, var(--primary));
  color: var(--pair-fg, var(--on-primary));
  transition: transform 190ms var(--ease-standard),
    box-shadow 190ms var(--ease-standard);
}

.pair:hover .pair__block {
  transform: translateY(-3px);
  box-shadow: var(--shadow-1);
}

.pair__block strong {
  font-size: 19px;
  line-height: 1.3;
  font-weight: 500;
}

.pair__block span {
  font-size: 13px;
  line-height: 1.5;
}

.pair__label {
  display: flex;
  flex-direction: column;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.45;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  white-space: normal;
  overflow-wrap: anywhere;
}

.role-groups {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.role-group__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.role-group__head h3 {
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
}

.role-group__head span {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 8px;
}

.role-card {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  text-align: left;
  transition: background-color 160ms var(--ease-standard),
    border-color 160ms var(--ease-standard);
}

.role-card:hover {
  background: var(--surface-1);
  border-color: var(--outline-variant);
}

.role-card__swatch {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: var(--r-xs);
  background: var(--role-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 7%, transparent);
}

.role-card__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}

.role-card__name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
  font-size: 13px;
  line-height: 1.45;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  white-space: normal;
  overflow-wrap: anywhere;
}

.role-card__hex {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.4;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  text-transform: uppercase;
}

.component-demo {
  padding: 24px;
  border-radius: var(--r-xl);
  background: var(--surface-1);
}

.component-demo__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 28px;
}

.demo-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.demo-col__label {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.demo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.demo-switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

md-outlined-text-field {
  width: 100%;
}

md-slider {
  width: 100%;
}

.system-caption {
  margin-top: 14px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   7. 对比度
   -------------------------------------------------------------------------- */

.contrast-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  gap: 32px;
  align-items: start;
}

.contrast-main {
  min-width: 0;
}

.preview {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  min-height: 360px;
  padding: 40px;
  border-radius: var(--r-xl);
  background: var(--preview-bg, #f4fbf4);
  color: var(--preview-fg, #0b2e2c);
  overflow: hidden;
  transition: background-color 260ms var(--ease-standard),
    color 260ms var(--ease-standard);
}

.preview::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 6%, transparent);
  pointer-events: none;
}

.preview__top h2 {
  font-family: var(--md-ref-typeface-brand);
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.preview__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 37em;
}

.preview__body p {
  font-size: 1rem;
  line-height: 1.8;
}

.preview__fine {
  font-size: 13px;
  line-height: 1.7;
}

.preview__caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-size: 13px;
  line-height: 1.6;
}

.preview__ratio {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.metrics {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1.6fr;
  gap: 24px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: var(--hairline);
}

.metric {
  min-width: 0;
}

.metric__label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.metric__value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1.75rem;
  line-height: 2.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.metric__value small {
  color: var(--on-surface-var);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
}

.metric__note {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.req-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 16px;
}

.req {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.req .material-symbols-outlined {
  font-size: 16px;
}

.req.is-pass {
  color: var(--on-surface);
}

.req.is-pass .material-symbols-outlined {
  color: var(--primary);
}

.req.is-fail .material-symbols-outlined {
  color: var(--error);
}

.contrast-panel {
  padding: 24px;
  border-radius: var(--r-xl);
  background: var(--surface-1);
}

.contrast-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.contrast-panel__head h2 {
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 500;
}

.color-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-control__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.color-control__label {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.color-control__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-control__swatch {
  position: relative;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: var(--r-xs);
  background: var(--ctrl-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 10%, transparent);
  overflow: hidden;
  cursor: pointer;
}

.color-control__swatch input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.color-control__fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.color-control__hex {
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 15px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.color-control__hex:hover {
  background: color-mix(in srgb, var(--on-surface) 6%, transparent);
}

.color-control__hex:focus {
  outline: none;
  background: var(--surface-3);
  box-shadow: 0 0 0 2px var(--primary);
}

.color-control__role {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.4;
  padding-left: 8px;
}

.swap-row {
  display: flex;
  justify-content: center;
  margin: 6px 0;
}

.swap-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--on-surface-var);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 160ms var(--ease-standard),
    color 160ms var(--ease-standard);
}

.swap-btn:hover {
  background: color-mix(in srgb, var(--on-surface) 7%, transparent);
  color: var(--on-surface);
}

.swap-btn .material-symbols-outlined {
  font-size: 17px;
}

.panel-divider {
  height: 1px;
  margin: 18px 0;
  background: var(--outline-variant);
}

.panel-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.panel-label span {
  font-weight: 400;
}

.palette-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.palette-pick {
  width: 32px;
  height: 32px;
  border-radius: var(--r-xs);
  background: var(--pick-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 10%, transparent);
  transition: transform 150ms var(--ease-standard),
    box-shadow 150ms var(--ease-standard);
}

.palette-pick:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-1);
}

.palette-pick.is-current {
  outline: 2px solid var(--on-surface);
  outline-offset: 2px;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}

.panel-note {
  margin-top: 10px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.cvd {
  margin-top: 40px;
  padding-top: 22px;
  border-top: var(--hairline);
}

.cvd__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
  margin-bottom: 18px;
}

.cvd__title h2 {
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 500;
}

.cvd__title p {
  margin-top: 2px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.cvd__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}

.cvd__severity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.cvd__severity label {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
}

.cvd__severity .range {
  width: 120px;
}

.cvd-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.cvd-card {
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-1);
}

.cvd-card__view {
  padding: 16px;
  background: var(--cvd-bg, #fff);
  color: var(--cvd-fg, #111);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
}

.cvd-card__view strong {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 600;
}

.cvd-card__view span {
  font-size: 13px;
  line-height: 1.55;
}

.cvd-card__strip {
  display: flex;
  gap: 2px;
  padding: 8px;
}

.cvd-card__strip span {
  flex: 1;
  height: 22px;
  border-radius: 3px;
}

.cvd-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px 12px;
}

.cvd-card__name {
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.cvd-card__ratio {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-family: ui-monospace, "Cascadia Mono", monospace;
}

/* --------------------------------------------------------------------------
   8. 图片取色
   -------------------------------------------------------------------------- */

.extract-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: clamp(460px, calc(100dvh - 190px), 840px);
  padding: 48px 24px;
  border: 1px dashed var(--outline);
  border-radius: var(--r-xl);
  text-align: center;
  transition: background-color 180ms var(--ease-standard),
    border-color 180ms var(--ease-standard);
}

.extract-empty.is-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.extract-empty__icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 24px;
  background: var(--surface-2);
  color: var(--on-surface-var);
}

.extract-empty__icon .material-symbols-outlined {
  font-size: 36px;
}

.extract-empty h2 {
  font-family: var(--md-ref-typeface-brand);
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 500;
}

.extract-empty p {
  max-width: 44ch;
  color: var(--on-surface-var);
  font-size: 14px;
  line-height: 1.7;
}

.extract-empty__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

p.extract-empty__formats {
  max-width: none;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  letter-spacing: 0.03em;
}

.extract-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 28px;
  align-items: start;
}

.extract-main {
  min-width: 0;
}

.extract-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
}

.file-chip .material-symbols-outlined {
  font-size: 18px;
}

.file-chip strong {
  overflow: hidden;
  color: var(--on-surface);
  font-size: 14px;
  font-weight: 500;
  max-width: 34ch;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.canvas-holder {
  position: relative;
  border-radius: var(--r-xl);
  background: var(--surface-1);
  overflow: hidden;
}

.canvas-holder canvas {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  cursor: crosshair;
}

.canvas-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.canvas-note .material-symbols-outlined {
  font-size: 17px;
}

.extract-results {
  padding: 22px;
  border-radius: var(--r-xl);
  background: var(--surface-1);
}

.extract-results__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.extract-results__head h2 {
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 500;
}

.extract-results__head span {
  color: var(--on-surface-var);
  font-size: 13px;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -8px 14px;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--r-xs);
  transition: background-color 150ms var(--ease-standard);
}

.result-row:hover {
  background: color-mix(in srgb, var(--on-surface) 6%, transparent);
}

.result-row__swatch {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--r-xs);
  background: var(--result-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent);
}

.result-row__body {
  flex: 1;
  min-width: 0;
}

.result-row__hex {
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 14px;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.result-row__bar {
  height: 3px;
  margin-top: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.result-row__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--result-color, var(--primary));
}

.result-row__pct {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  min-width: 4.5ch;
  text-align: right;
}

.result-row__actions {
  display: flex;
  gap: 0;
  flex: none;
}

.result-row__actions .icon-btn {
  width: 30px;
  height: 30px;
}

.result-row__actions .material-symbols-outlined {
  font-size: 17px;
}

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

.extract-side {
  margin-top: 18px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.65;
}

.extract-side strong {
  color: var(--on-surface);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   9. 收藏
   -------------------------------------------------------------------------- */

.library-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.library-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
}

.search .material-symbols-outlined {
  position: absolute;
  left: 13px;
  color: var(--on-surface-var);
  font-size: 20px;
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1.5;
  transition: background-color 170ms var(--ease-standard),
    border-color 170ms var(--ease-standard);
}

.search input::placeholder {
  color: var(--on-surface-var);
}

.search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface-1);
}

.library-section {
  margin-bottom: 34px;
}

.library-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.library-section__head h2 {
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 500;
}

.library-section__head p {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.lib-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  overflow: hidden;
  transition: border-color 180ms var(--ease-standard),
    box-shadow 220ms var(--ease-standard),
    transform 220ms var(--ease-standard);
}

.lib-card:hover {
  border-color: var(--outline-variant);
  box-shadow: var(--shadow-1);
  transform: translateY(-2px);
}

.lib-card.is-current {
  border-color: var(--primary);
}

.lib-card__load {
  display: flex;
  flex-direction: column;
  text-align: left;
  width: 100%;
}

.lib-card__strip {
  display: flex;
  gap: 2px;
  height: 108px;
  background: var(--surface-0);
}

.lib-card__strip span {
  flex: 1;
  min-width: 0;
}

.lib-card__body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px 15px;
}

.lib-card__name {
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lib-card__meta {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
}

.lib-card__flag {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-0) 92%, transparent);
  color: var(--on-surface);
  font-size: 13px;
  line-height: 1;
  font-weight: 500;
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(6px);
}

.lib-card__menu {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface-0) 88%, transparent);
  color: var(--on-surface);
  box-shadow: var(--shadow-1);
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 160ms var(--ease-standard),
    transform 160ms var(--ease-standard);
}

.lib-card:hover .lib-card__menu,
.lib-card:focus-within .lib-card__menu {
  opacity: 1;
  transform: none;
}

@media (hover: none) {
  .lib-card__menu {
    opacity: 1;
    transform: none;
  }
}

.library-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 26px;
  border: 1px dashed var(--outline);
  border-radius: var(--r-lg);
  color: var(--on-surface-var);
  font-size: 14px;
  line-height: 1.6;
}

.library-empty strong {
  color: var(--on-surface);
  font-size: 15px;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   10. 导出
   -------------------------------------------------------------------------- */

.export-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
}

.export-ident {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.export-strip {
  display: flex;
  gap: 2px;
  width: 168px;
  height: 36px;
  flex: none;
  border-radius: var(--r-xs);
  overflow: hidden;
  background: var(--surface-3);
}

.export-strip span {
  flex: 1;
  min-width: 0;
}

.export-ident__text {
  min-width: 0;
}

.export-ident__text strong {
  display: block;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.export-ident__text span {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-family: ui-monospace, "Cascadia Mono", monospace;
}

.export-layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.export-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.export-group {
  margin: 16px 0 6px;
  padding: 0 10px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.export-group:first-child {
  margin-top: 0;
}

.export-option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 10px;
  border-radius: var(--r-sm);
  text-align: left;
  transition: background-color 160ms var(--ease-standard);
}

.export-option:hover {
  background: var(--surface-1);
}

.export-option.is-active {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.export-option__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: color-mix(in srgb, var(--on-surface) 6%, transparent);
}

.export-option.is-active .export-option__icon {
  background: color-mix(in srgb, var(--on-secondary-container) 10%, transparent);
}

.export-option__icon .material-symbols-outlined {
  font-size: 19px;
}

.export-option__text {
  min-width: 0;
}

.export-option__name,
.export-option__desc {
  display: block;
}

.export-option__name {
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
}

.export-option__desc {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
}

.export-option.is-active .export-option__desc {
  color: var(--on-secondary-container);
}

.export-main {
  min-width: 0;
}

.export-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.export-file {
  min-width: 0;
}

.export-file strong {
  display: block;
  overflow: hidden;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.export-file span {
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.5;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.export-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--r-sm);
  background: var(--surface-1);
}

.export-option-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--on-surface-var);
}

.export-option-field input[type="text"] {
  width: 130px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-3);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.export-option-field input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.code-panel {
  border-radius: var(--r-md);
  background: var(--surface-lowest);
  box-shadow: inset 0 0 0 1px var(--outline-variant);
  overflow: hidden;
}

.code-panel pre {
  max-height: 560px;
  margin: 0;
  padding: 18px 20px;
  overflow: auto;
  color: var(--on-surface);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono",
    monospace;
  font-size: 13px;
  line-height: 1.75;
  tab-size: 2;
  white-space: pre;
}

.poster-preview {
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: var(--r-md);
  background: var(--surface-1);
}

.poster-preview img {
  max-height: 380px;
  width: auto;
  border-radius: 6px;
  box-shadow: var(--shadow-1);
}

.export-note {
  margin-top: 12px;
  color: var(--on-surface-var);
  font-size: 13px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   11. 响应式
   -------------------------------------------------------------------------- */

@media (max-width: 1360px) {
  :root {
    --pad-x: 32px;
  }

  .source-strip {
    flex-wrap: wrap;
    gap: 22px 28px;
  }

  .role-strip {
    order: 3;
    flex-basis: 100%;
    min-width: 0;
  }

  .role-strip__chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .source-actions {
    margin-left: auto;
  }

  .inspect__top {
    grid-template-columns: 220px minmax(0, 1fr) 260px;
    gap: 26px;
  }

  .component-demo__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1220px) {
  .wheel-layout,
  .contrast-layout,
  .extract-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 26px;
  }

  .pairs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cvd-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inspect__top {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .inspect__contrast {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 32px;
    padding-left: 0;
    padding-top: 18px;
    border-left: 0;
    border-top: var(--hairline);
  }

  .inspect__contrast .inspect__label {
    grid-column: 1 / -1;
  }

  .contrast-mini {
    flex-direction: row;
    gap: 12px;
  }

  .contrast-mini__row {
    flex: 1;
  }

  .contrast-mini__link {
    margin-top: 8px;
  }
}

@media (max-width: 1040px) {
  :root {
    --rail-w: 0px;
    --pad-x: 24px;
    --topbar-h: 68px;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    display: none;
  }

  .topbar__menu {
    display: inline-grid;
    margin-left: -8px;
  }

  .wheel-layout,
  .contrast-layout,
  .extract-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .wheel-panel {
    max-width: 640px;
  }

  .wheel-stage {
    align-items: flex-start;
  }

  .contrast-panel {
    max-width: 640px;
  }

  .export-layout {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .library-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .metrics .metric:last-child {
    grid-column: 1 / -1;
    padding-top: 14px;
    border-top: var(--hairline-soft);
  }
}

@media (max-width: 820px) {
  :root {
    --pad-x: 20px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar__sub {
    display: none;
  }

  .topbar__title {
    font-size: 1.25rem;
    line-height: 1.5rem;
  }

  .seed-chip {
    display: none;
  }

  #btn-save {
    width: 40px;
    padding: 0;
  }

  .topbar__actions {
    gap: 4px;
  }

  .btn__label {
    display: none;
  }

  #btn-export-top {
    width: 40px;
    padding: 0;
  }

  .content {
    padding-top: 18px;
  }

  .source-strip {
    gap: 18px;
  }

  .source {
    width: 100%;
  }

  .source__orb-wrap {
    width: 92px;
    height: 92px;
  }

  .source__orb {
    inset: 11px;
  }

  .source__hex-input {
    font-size: 1.125rem;
  }

  .source-actions {
    width: 100%;
    flex-direction: row;
    margin-left: 0;
  }

  .source-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .source-actions .btn--text {
    flex: 0 0 auto;
  }

  .role-strip {
    order: 0;
  }

  .palette-name {
    font-size: 1.375rem;
    line-height: 1.75rem;
    max-width: 62vw;
  }

  .palette-head {
    align-items: flex-start;
  }

  .palette-tools {
    width: 100%;
    justify-content: space-between;
  }

  .palette-tools .segmented {
    flex: 1;
  }

  .palette-tools .segmented button {
    flex: 1;
    padding: 0 8px;
  }

  .deck {
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 132px;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 0 10px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .swatch {
    scroll-snap-align: start;
  }

  .swatch__color {
    height: 300px;
  }

  .swatch__more {
    opacity: 1;
    transform: none;
  }

  .inspect {
    padding: 18px;
  }

  .inspect__top {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .inspect__chip {
    height: 120px;
  }

  .formats {
    grid-template-columns: 1fr;
  }

  .inspect__contrast {
    display: block;
  }

  .contrast-mini {
    flex-direction: column;
  }

  .ramp__cells {
    display: grid;
    grid-template-columns: repeat(11, minmax(0, 1fr));
    gap: 4px;
    overflow: visible;
  }

  .ramp__cell {
    min-width: 0;
  }

  .ramp__fill {
    height: 44px;
  }

  .ramp__tone {
    font-size: 12px;
  }

  .tonal-scroll-hint {
    display: flex;
  }

  .tonal-label {
    background: var(--surface);
    box-shadow: 10px 0 10px -12px color-mix(in srgb, var(--on-surface) 40%, transparent);
  }

  .preset-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .preset-card__strip {
    height: 76px;
  }

  .wheel-panel {
    padding: 20px;
  }

  .pairs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .component-demo {
    padding: 20px;
  }

  .component-demo__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .preview {
    min-height: 300px;
    padding: 26px;
  }

  .metrics {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .metrics .metric:last-child {
    grid-column: auto;
    padding-top: 0;
    border-top: 0;
  }

  .req-list {
    grid-template-columns: 1fr;
  }

  .cvd-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .cvd__severity {
    min-width: 0;
  }

  .cvd__severity .range {
    width: 100px;
  }

  .export-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .export-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
  }

  .export-group {
    grid-column: 1 / -1;
  }

  .export-option {
    padding: 8px;
  }

  .export-option__icon {
    display: none;
  }

  .library-bar {
    align-items: flex-start;
  }

  .search {
    width: 100%;
  }

  .library-filter {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .library-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    padding: 20px;
    border-radius: var(--r-xl);
  }

  .setting {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .setting md-switch {
    align-self: flex-start;
  }

  .shortcuts {
    grid-template-columns: 1fr;
  }

  .dialog__foot {
    flex-wrap: wrap;
  }

  .help__note {
    flex-basis: 100%;
    margin-bottom: 6px;
  }
}

@media (max-width: 560px) {
  :root {
    --pad-x: 16px;
  }

  .topbar__title {
    font-size: 1.125rem;
  }

  .source__orb-wrap {
    width: 84px;
    height: 84px;
  }

  .source__orb {
    inset: 10px;
  }

  .source__hint {
    display: none;
  }

  .source-actions {
    flex-wrap: wrap;
  }

  .source-actions .btn {
    flex: 1 1 100%;
  }

  .source-actions .btn--text {
    flex: 1 1 auto;
  }

  .role-chip {
    width: 58px;
    flex: none;
  }

  .palette-name {
    max-width: 58vw;
    font-size: 1.25rem;
  }

  .palette-tools .segmented button {
    font-size: 12.5px;
  }

  .palette-tools .btn--filled {
    padding: 0 14px;
  }

  .palette-tools .btn--filled .btn__label {
    display: none;
  }

  .swatch__color {
    height: 260px;
  }

  .inspect {
    border-radius: var(--r-lg);
  }

  .inspect__name h3 {
    font-size: 1.125rem;
  }

  .inspect__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .inspect__actions .btn {
    --btn-h: 44px;
    justify-content: center;
  }

  .section-head__tools {
    width: 100%;
  }

  .pairs {
    grid-template-columns: minmax(0, 1fr);
  }

  .pair__block {
    height: 68px;
  }

  .wheel__disc-center {
    width: 58px;
    height: 58px;
  }

  .wheel__pin {
    width: 13px;
    height: 13px;
  }

  .wheel__pin.is-base {
    width: 18px;
    height: 18px;
  }

  .preview {
    padding: 22px;
  }

  .preview__body p {
    font-size: 0.9375rem;
  }

  .metrics {
    gap: 14px;
  }

  .metric__value {
    font-size: 1.5rem;
    line-height: 2rem;
  }

  .library-section__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .export-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .export-ident {
    flex-wrap: wrap;
  }

  .export-strip {
    width: 140px;
  }

  .export-actions {
    width: 100%;
  }

  .export-actions .btn {
    flex: 1;
  }

  .poster-preview {
    padding: 10px;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
    transform: translateY(18px);
  }

  .toast.is-visible {
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   12. 动效开关 & 减少动态效果
   -------------------------------------------------------------------------- */

body.no-motion .view,
body.no-motion .deck--enter .swatch,
body.no-motion .role-chip.is-refreshing .role-chip__fill,
body.no-motion .swatch,
body.no-motion .toast {
  animation: none !important;
}

body.no-motion *,
body.no-motion *::before,
body.no-motion *::after {
  transition-duration: 0.01ms !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}

body.no-motion .swatch__color:hover,
body.no-motion .preset-card:hover .preset-card__strip,
body.no-motion .pair:hover .pair__block,
body.no-motion .ramp__cell:hover .ramp__fill,
body.no-motion .role-chip:hover .role-chip__fill {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .view,
  .deck--enter .swatch {
    animation: none !important;
  }
}

/* 通用小工具 ------------------------------------------------------------- */

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

/* 添加颜色对话框的预览 */
.add-preview {
  display: flex;
  align-items: flex-end;
  height: 116px;
  margin: 2px 0 18px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--preview-color, var(--primary));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 8%, transparent);
  transition: background-color 200ms var(--ease-standard);
}

.add-preview__hex {
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, #000 58%, transparent);
  color: #fff;
  font-family: ui-monospace, "Cascadia Mono", "Roboto Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

/* 触屏没有悬停手柄，排序交给菜单里的左右移动 */
@media (hover: none) {
  .swatch__drag {
    display: none;
  }
}

/* 打印 */
@media print {
  .rail,
  .topbar,
  .toast,
  .presets {
    display: none !important;
  }

  .app {
    display: block;
  }

  .content {
    padding: 0;
  }
}
