/* ===== M3 参考色调色板 (tonal palettes, L* tones) ===== */
:root {
  --md-ref-palette-primary-0: #000100;
  --md-ref-palette-primary-4: #00120E;
  --md-ref-palette-primary-6: #001813;
  --md-ref-palette-primary-10: #00211B;
  --md-ref-palette-primary-12: #002520;
  --md-ref-palette-primary-17: #00312A;
  --md-ref-palette-primary-20: #003830;
  --md-ref-palette-primary-22: #003D35;
  --md-ref-palette-primary-24: #004139;
  --md-ref-palette-primary-25: #00443B;
  --md-ref-palette-primary-30: #005147;
  --md-ref-palette-primary-35: #005E52;
  --md-ref-palette-primary-40: #006B5E;
  --md-ref-palette-primary-50: #008677;
  --md-ref-palette-primary-60: #00A391;
  --md-ref-palette-primary-70: #39BEAB;
  --md-ref-palette-primary-80: #5BDAC6;
  --md-ref-palette-primary-87: #71EFDA;
  --md-ref-palette-primary-90: #7AF7E2;
  --md-ref-palette-primary-92: #80FDE8;
  --md-ref-palette-primary-94: #A0FFEE;
  --md-ref-palette-primary-95: #B4FFF1;
  --md-ref-palette-primary-96: #C5FFF3;
  --md-ref-palette-primary-98: #E4FFF9;
  --md-ref-palette-primary-99: #F1FFFC;
  --md-ref-palette-primary-100: #FEFFFF;
  --md-ref-palette-secondary-0: #000100;
  --md-ref-palette-secondary-4: #00120E;
  --md-ref-palette-secondary-6: #001813;
  --md-ref-palette-secondary-10: #00211B;
  --md-ref-palette-secondary-12: #002520;
  --md-ref-palette-secondary-17: #05302A;
  --md-ref-palette-secondary-20: #0D3730;
  --md-ref-palette-secondary-22: #123B35;
  --md-ref-palette-secondary-24: #174039;
  --md-ref-palette-secondary-25: #1A423B;
  --md-ref-palette-secondary-30: #264E47;
  --md-ref-palette-secondary-35: #325952;
  --md-ref-palette-secondary-40: #3E665E;
  --md-ref-palette-secondary-50: #567F77;
  --md-ref-palette-secondary-60: #6F9991;
  --md-ref-palette-secondary-70: #89B4AB;
  --md-ref-palette-secondary-80: #A4CFC6;
  --md-ref-palette-secondary-87: #B7E3DA;
  --md-ref-palette-secondary-90: #BFEBE2;
  --md-ref-palette-secondary-92: #C5F1E8;
  --md-ref-palette-secondary-94: #CAF7EE;
  --md-ref-palette-secondary-95: #CDFAF1;
  --md-ref-palette-secondary-96: #D0FDF3;
  --md-ref-palette-secondary-98: #E4FFF9;
  --md-ref-palette-secondary-99: #F1FFFC;
  --md-ref-palette-secondary-100: #FEFFFF;
  --md-ref-palette-tertiary-0: #050000;
  --md-ref-palette-tertiary-4: #1B0A00;
  --md-ref-palette-tertiary-6: #210F00;
  --md-ref-palette-tertiary-10: #2D1600;
  --md-ref-palette-tertiary-12: #341900;
  --md-ref-palette-tertiary-17: #402309;
  --md-ref-palette-tertiary-20: #472911;
  --md-ref-palette-tertiary-22: #4C2E15;
  --md-ref-palette-tertiary-24: #513219;
  --md-ref-palette-tertiary-25: #54341C;
  --md-ref-palette-tertiary-30: #603F26;
  --md-ref-palette-tertiary-35: #6D4B31;
  --md-ref-palette-tertiary-40: #7A573C;
  --md-ref-palette-tertiary-50: #956F54;
  --md-ref-palette-tertiary-60: #B1886C;
  --md-ref-palette-tertiary-70: #CDA385;
  --md-ref-palette-tertiary-80: #E9BEA0;
  --md-ref-palette-tertiary-87: #FED1B3;
  --md-ref-palette-tertiary-90: #FFDCC4;
  --md-ref-palette-tertiary-92: #FFE3D0;
  --md-ref-palette-tertiary-94: #FFEADC;
  --md-ref-palette-tertiary-95: #FFEDE2;
  --md-ref-palette-tertiary-96: #FFF1E8;
  --md-ref-palette-tertiary-98: #FFF8F3;
  --md-ref-palette-tertiary-99: #FFFBF9;
  --md-ref-palette-tertiary-100: #FFFFFF;
  --md-ref-palette-error-0: #0A0000;
  --md-ref-palette-error-4: #220500;
  --md-ref-palette-error-6: #2A0800;
  --md-ref-palette-error-10: #3C0900;
  --md-ref-palette-error-12: #450700;
  --md-ref-palette-error-17: #5D0000;
  --md-ref-palette-error-20: #650905;
  --md-ref-palette-error-22: #6B100B;
  --md-ref-palette-error-24: #711610;
  --md-ref-palette-error-25: #741912;
  --md-ref-palette-error-30: #82261C;
  --md-ref-palette-error-35: #903327;
  --md-ref-palette-error-40: #9F4032;
  --md-ref-palette-error-50: #BD5949;
  --md-ref-palette-error-60: #DB7361;
  --md-ref-palette-error-70: #F98E7A;
  --md-ref-palette-error-80: #FFB4A5;
  --md-ref-palette-error-87: #FFCFC5;
  --md-ref-palette-error-90: #FFDAD3;
  --md-ref-palette-error-92: #FFE2DC;
  --md-ref-palette-error-94: #FFE9E5;
  --md-ref-palette-error-95: #FFEDE9;
  --md-ref-palette-error-96: #FFF0ED;
  --md-ref-palette-error-98: #FFF8F6;
  --md-ref-palette-error-99: #FFFBFB;
  --md-ref-palette-error-100: #FFFFFF;
  --md-ref-palette-neutral-0: #000100;
  --md-ref-palette-neutral-4: #04100E;
  --md-ref-palette-neutral-6: #0B1513;
  --md-ref-palette-neutral-10: #151D1B;
  --md-ref-palette-neutral-12: #19211F;
  --md-ref-palette-neutral-17: #232C2A;
  --md-ref-palette-neutral-20: #2A3230;
  --md-ref-palette-neutral-22: #2E3635;
  --md-ref-palette-neutral-24: #323B39;
  --md-ref-palette-neutral-25: #353D3B;
  --md-ref-palette-neutral-30: #404947;
  --md-ref-palette-neutral-35: #4B5452;
  --md-ref-palette-neutral-40: #57605E;
  --md-ref-palette-neutral-50: #6F7977;
  --md-ref-palette-neutral-60: #899391;
  --md-ref-palette-neutral-70: #A3ADAB;
  --md-ref-palette-neutral-80: #BEC9C6;
  --md-ref-palette-neutral-87: #D2DCDA;
  --md-ref-palette-neutral-90: #DAE5E2;
  --md-ref-palette-neutral-92: #E0EAE8;
  --md-ref-palette-neutral-94: #E5F0EE;
  --md-ref-palette-neutral-95: #E8F3F1;
  --md-ref-palette-neutral-96: #EBF6F3;
  --md-ref-palette-neutral-98: #F1FCF9;
  --md-ref-palette-neutral-99: #F4FEFC;
  --md-ref-palette-neutral-100: #FEFFFF;
  --md-ref-palette-nvariant-0: #000100;
  --md-ref-palette-nvariant-4: #00120E;
  --md-ref-palette-nvariant-6: #011713;
  --md-ref-palette-nvariant-10: #0E1E1B;
  --md-ref-palette-nvariant-12: #12231F;
  --md-ref-palette-nvariant-17: #1C2D2A;
  --md-ref-palette-nvariant-20: #223430;
  --md-ref-palette-nvariant-22: #273835;
  --md-ref-palette-nvariant-24: #2B3D39;
  --md-ref-palette-nvariant-25: #2D3F3B;
  --md-ref-palette-nvariant-30: #384A47;
  --md-ref-palette-nvariant-35: #445652;
  --md-ref-palette-nvariant-40: #4F625E;
  --md-ref-palette-nvariant-50: #687B77;
  --md-ref-palette-nvariant-60: #819591;
  --md-ref-palette-nvariant-70: #9BAFAB;
  --md-ref-palette-nvariant-80: #B6CBC6;
  --md-ref-palette-nvariant-87: #C9DFDA;
  --md-ref-palette-nvariant-90: #D1E7E2;
  --md-ref-palette-nvariant-92: #D7EDE8;
  --md-ref-palette-nvariant-94: #DDF2EE;
  --md-ref-palette-nvariant-95: #E0F5F1;
  --md-ref-palette-nvariant-96: #E3F8F3;
  --md-ref-palette-nvariant-98: #E8FEF9;
  --md-ref-palette-nvariant-99: #F1FFFC;
  --md-ref-palette-nvariant-100: #FEFFFF;
}

/* ===== M3 亮色配色方案 (light color scheme) ===== */
:root, .theme-light {
  --md-sys-color-primary: #006B5E;
  --md-sys-color-on-primary: #FEFFFF;
  --md-sys-color-primary-container: #7AF7E2;
  --md-sys-color-on-primary-container: #00211B;
  --md-sys-color-primary-fixed: #7AF7E2;
  --md-sys-color-primary-fixed-dim: #5BDAC6;
  --md-sys-color-on-primary-fixed: #00211B;
  --md-sys-color-on-primary-fixed-variant: #005147;
  --md-sys-color-secondary: #3E665E;
  --md-sys-color-on-secondary: #FEFFFF;
  --md-sys-color-secondary-container: #BFEBE2;
  --md-sys-color-on-secondary-container: #00211B;
  --md-sys-color-tertiary: #7A573C;
  --md-sys-color-on-tertiary: #FFFFFF;
  --md-sys-color-tertiary-container: #FFDCC4;
  --md-sys-color-on-tertiary-container: #2D1600;
  --md-sys-color-error: #9F4032;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #FFDAD3;
  --md-sys-color-on-error-container: #3C0900;
  --md-sys-color-background: #F4FEFC;
  --md-sys-color-on-background: #151D1B;
  --md-sys-color-surface: #F1FCF9;
  --md-sys-color-on-surface: #151D1B;
  --md-sys-color-surface-variant: #D1E7E2;
  --md-sys-color-on-surface-variant: #384A47;
  --md-sys-color-surface-dim: #D2DCDA;
  --md-sys-color-surface-bright: #F1FCF9;
  --md-sys-color-surface-container-lowest: #FEFFFF;
  --md-sys-color-surface-container-low: #EBF6F3;
  --md-sys-color-surface-container: #E5F0EE;
  --md-sys-color-surface-container-high: #E0EAE8;
  --md-sys-color-surface-container-highest: #DAE5E2;
  --md-sys-color-surface-tint: #006B5E;
  --md-sys-color-inverse-surface: #2A3230;
  --md-sys-color-inverse-on-surface: #E8F3F1;
  --md-sys-color-inverse-primary: #5BDAC6;
  --md-sys-color-outline: #687B77;
  --md-sys-color-outline-variant: #B6CBC6;
  --md-sys-color-scrim: #000100;
  --md-sys-color-shadow: #000100;
}

/* ===== M3 暗色配色方案 (dark color scheme) ===== */
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) {
    --md-sys-color-primary: #5BDAC6;
    --md-sys-color-on-primary: #003830;
    --md-sys-color-primary-container: #005147;
    --md-sys-color-on-primary-container: #7AF7E2;
    --md-sys-color-primary-fixed: #7AF7E2;
    --md-sys-color-primary-fixed-dim: #5BDAC6;
    --md-sys-color-on-primary-fixed: #00211B;
    --md-sys-color-on-primary-fixed-variant: #005147;
    --md-sys-color-secondary: #A4CFC6;
    --md-sys-color-on-secondary: #0D3730;
    --md-sys-color-secondary-container: #264E47;
    --md-sys-color-on-secondary-container: #BFEBE2;
    --md-sys-color-tertiary: #E9BEA0;
    --md-sys-color-on-tertiary: #472911;
    --md-sys-color-tertiary-container: #603F26;
    --md-sys-color-on-tertiary-container: #FFDCC4;
    --md-sys-color-error: #FFB4A5;
    --md-sys-color-on-error: #650905;
    --md-sys-color-error-container: #82261C;
    --md-sys-color-on-error-container: #FFDAD3;
    --md-sys-color-background: #0B1513;
    --md-sys-color-on-background: #DAE5E2;
    --md-sys-color-surface: #0B1513;
    --md-sys-color-on-surface: #DAE5E2;
    --md-sys-color-surface-variant: #384A47;
    --md-sys-color-on-surface-variant: #B6CBC6;
    --md-sys-color-surface-dim: #0B1513;
    --md-sys-color-surface-bright: #323B39;
    --md-sys-color-surface-container-lowest: #04100E;
    --md-sys-color-surface-container-low: #151D1B;
    --md-sys-color-surface-container: #19211F;
    --md-sys-color-surface-container-high: #232C2A;
    --md-sys-color-surface-container-highest: #2E3635;
    --md-sys-color-surface-tint: #5BDAC6;
    --md-sys-color-inverse-surface: #DAE5E2;
    --md-sys-color-inverse-on-surface: #2A3230;
    --md-sys-color-inverse-primary: #006B5E;
    --md-sys-color-outline: #819591;
    --md-sys-color-outline-variant: #384A47;
    --md-sys-color-scrim: #000100;
    --md-sys-color-shadow: #000100;
  }
}

/* 手动切换暗色 */
.theme-dark {
  --md-sys-color-primary: #5BDAC6;
  --md-sys-color-on-primary: #003830;
  --md-sys-color-primary-container: #005147;
  --md-sys-color-on-primary-container: #7AF7E2;
  --md-sys-color-primary-fixed: #7AF7E2;
  --md-sys-color-primary-fixed-dim: #5BDAC6;
  --md-sys-color-on-primary-fixed: #00211B;
  --md-sys-color-on-primary-fixed-variant: #005147;
  --md-sys-color-secondary: #A4CFC6;
  --md-sys-color-on-secondary: #0D3730;
  --md-sys-color-secondary-container: #264E47;
  --md-sys-color-on-secondary-container: #BFEBE2;
  --md-sys-color-tertiary: #E9BEA0;
  --md-sys-color-on-tertiary: #472911;
  --md-sys-color-tertiary-container: #603F26;
  --md-sys-color-on-tertiary-container: #FFDCC4;
  --md-sys-color-error: #FFB4A5;
  --md-sys-color-on-error: #650905;
  --md-sys-color-error-container: #82261C;
  --md-sys-color-on-error-container: #FFDAD3;
  --md-sys-color-background: #0B1513;
  --md-sys-color-on-background: #DAE5E2;
  --md-sys-color-surface: #0B1513;
  --md-sys-color-on-surface: #DAE5E2;
  --md-sys-color-surface-variant: #384A47;
  --md-sys-color-on-surface-variant: #B6CBC6;
  --md-sys-color-surface-dim: #0B1513;
  --md-sys-color-surface-bright: #323B39;
  --md-sys-color-surface-container-lowest: #04100E;
  --md-sys-color-surface-container-low: #151D1B;
  --md-sys-color-surface-container: #19211F;
  --md-sys-color-surface-container-high: #232C2A;
  --md-sys-color-surface-container-highest: #2E3635;
  --md-sys-color-surface-tint: #5BDAC6;
  --md-sys-color-inverse-surface: #DAE5E2;
  --md-sys-color-inverse-on-surface: #2A3230;
  --md-sys-color-inverse-primary: #006B5E;
  --md-sys-color-outline: #819591;
  --md-sys-color-outline-variant: #384A47;
  --md-sys-color-scrim: #000100;
  --md-sys-color-shadow: #000100;
}

/* ============================================================
   color-scheme 声明
   令牌优先级（高 → 低）：
     1. :root.theme-light / :root.theme-dark  用户手动切换
     2. @media (prefers-color-scheme: dark)   跟随系统
     3. :root 默认亮色
   ============================================================ */
@media (prefers-color-scheme: light) {
  :root:not(.theme-dark) { color-scheme: light; }
}
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) { color-scheme: dark; }
}
