/* ==========================================================================
   MATERIAL 3 THEME TOKENS (light.css & dark.css)
   ========================================================================== */
:root, .light {
  --md-sys-color-primary: #8B4513;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #FFDBC8;
  --md-sys-color-on-primary-container: #321200;
  --md-sys-color-secondary: #755847;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #FFDBC8;
  --md-sys-color-on-secondary-container: #2B1709;
  --md-sys-color-tertiary: #626033;
  --md-sys-color-on-tertiary: #FFFFFF;
  --md-sys-color-tertiary-container: #E8E5AC;
  --md-sys-color-on-tertiary-container: #1E1D00;
  --md-sys-color-error: #BA1A1A;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #FFDAD6;
  --md-sys-color-on-error-container: #410002;
  --md-sys-color-success: #2E6B38;
  --md-sys-color-on-success: #FFFFFF;
  --md-sys-color-success-container: #B4F1B3;
  --md-sys-color-on-success-container: #002107;
  --md-sys-color-warning-container: #FFE08E;
  --md-sys-color-on-warning-container: #261900;
  --md-sys-color-background: #FFF8F5;
  --md-sys-color-on-background: #221A15;
  --md-sys-color-surface: #FFF8F5;
  --md-sys-color-on-surface: #221A15;
  --md-sys-color-surface-variant: #F4DED3;
  --md-sys-color-on-surface-variant: #52443C;
  --md-sys-color-outline: #85736B;
  --md-sys-color-outline-variant: #D7C2B8;
  --md-sys-color-surface-container-lowest: #FFFFFF;
  --md-sys-color-surface-container-low: #FFF1EB;
  --md-sys-color-surface-container: #FCEAE2;
  --md-sys-color-surface-container-high: #F6E4DC;
  --md-sys-color-surface-container-highest: #F0DFD7;
}

.dark {
  --md-sys-color-primary: #FFB68C;
  --md-sys-color-on-primary: #522300;
  --md-sys-color-primary-container: #6F3405;
  --md-sys-color-on-primary-container: #FFDBC8;
  --md-sys-color-secondary: #E5BFA9;
  --md-sys-color-on-secondary: #422B1C;
  --md-sys-color-secondary-container: #5B4131;
  --md-sys-color-on-secondary-container: #FFDBC8;
  --md-sys-color-tertiary: #CCC992;
  --md-sys-color-on-tertiary: #333209;
  --md-sys-color-tertiary-container: #4A481E;
  --md-sys-color-on-tertiary-container: #E8E5AC;
  --md-sys-color-error: #FFB4AB;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000A;
  --md-sys-color-on-error-container: #FFDAD6;
  --md-sys-color-success: #99D499;
  --md-sys-color-on-success: #00390F;
  --md-sys-color-success-container: #135222;
  --md-sys-color-on-success-container: #B4F1B3;
  --md-sys-color-warning-container: #5C4300;
  --md-sys-color-on-warning-container: #FFE08E;
  --md-sys-color-background: #1A120D;
  --md-sys-color-on-background: #F0DFD7;
  --md-sys-color-surface: #1A120D;
  --md-sys-color-on-surface: #F0DFD7;
  --md-sys-color-surface-variant: #52443C;
  --md-sys-color-on-surface-variant: #D7C2B8;
  --md-sys-color-outline: #9F8D83;
  --md-sys-color-outline-variant: #52443C;
  --md-sys-color-surface-container-lowest: #140D08;
  --md-sys-color-surface-container-low: #221A15;
  --md-sys-color-surface-container: #271E19;
  --md-sys-color-surface-container-high: #322823;
  --md-sys-color-surface-container-highest: #3D332D;
}

/* ==========================================================================
   TYPOGRAPHY & M3 EXPRESSIVE SPRING PHYSICS (ZERO BLUR, ZERO OUTLINE)
   ========================================================================== */
:root {
  --m3ex-spring-expressive: cubic-bezier(0.34, 1.56, 0.64, 1);
  --m3ex-spring-spatial: cubic-bezier(0.22, 1.32, 0.36, 1);
  --m3ex-spring-snappy: cubic-bezier(0.2, 0.9, 0.3, 1.25);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Roboto Flex', sans-serif;
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  margin: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.m3ex-display {
  font-variation-settings: 'wght' 850, 'wdth' 120, 'opsz' 48, 'GRAD' 50;
  letter-spacing: -0.02em;
  line-height: 1.12;
}

.m3ex-headline {
  font-variation-settings: 'wght' 750, 'wdth' 112, 'opsz' 32, 'GRAD' 25;
  letter-spacing: -0.01em;
}

.m3ex-title {
  font-variation-settings: 'wght' 700, 'wdth' 105, 'opsz' 20;
}

.m3ex-label {
  font-variation-settings: 'wght' 650, 'wdth' 108, 'opsz' 14;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   MATERIAL YOU TONAL HIERARCHY & EXPRESSIVE SHAPES
   ========================================================================== */
.m3ex-card {
  background-color: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  border: none;
  border-radius: 28px;
  transition: border-radius 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              background-color 0.2s ease,
              transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.m3ex-shape-arch {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border: none;
  border-radius: 56px 56px 26px 26px;
  transition: border-radius 0.42s var(--m3ex-spring-expressive),
              transform 0.35s var(--m3ex-spring-expressive);
}

@media (hover: hover) {
  .m3ex-shape-arch:hover {
    border-radius: 42px 64px 28px 34px;
    transform: translateY(-2px);
  }
}

.m3ex-shape-slanted {
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
  border: none;
  border-radius: 38px 18px 38px 18px;
  transition: border-radius 0.42s var(--m3ex-spring-expressive),
              transform 0.35s var(--m3ex-spring-expressive);
}

@media (hover: hover) {
  .m3ex-shape-slanted:hover {
    border-radius: 22px 44px 22px 44px;
    transform: translateY(-2px);
  }
}

.m3ex-cookie-badge {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variation-settings: 'wght' 800, 'wdth' 115;
  flex-shrink: 0;
  transition: background-color 0.22s ease,
              color 0.22s ease,
              transform 0.42s var(--m3ex-spring-expressive);
}

.part-row.active-part .m3ex-cookie-badge {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  transform: scale(1.12) rotate(14deg);
}

.m3ex-morph-item {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border: none;
  border-radius: 18px;
  cursor: pointer;
  user-select: none;
  transition: border-radius 0.38s var(--m3ex-spring-expressive),
              background-color 0.2s ease,
              color 0.2s ease,
              font-variation-settings 0.28s var(--m3ex-spring-expressive),
              transform 0.24s var(--m3ex-spring-expressive);
}

@media (hover: hover) {
  .m3ex-morph-item:hover {
    transform: translateY(-1px);
  }
}

.m3ex-morph-item:active {
  transform: scale(0.95);
}

.m3ex-morph-item.selected {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-radius: 40px;
  font-variation-settings: 'wght' 750, 'wdth' 108;
}

/* Buttons */
.m3ex-btn-primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  border-radius: 9999px;
  font-variation-settings: 'wght' 700, 'wdth' 110;
  transition: border-radius 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.15s ease;
}

.m3ex-btn-primary:active {
  border-radius: 18px;
  transform: scale(0.97);
}

.m3ex-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.m3ex-btn-tonal {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border: none;
  border-radius: 9999px;
  font-variation-settings: 'wght' 650, 'wdth' 105;
  transition: border-radius 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.m3ex-btn-tonal:active {
  border-radius: 16px;
  transform: scale(0.97);
}

.m3ex-btn-success {
  background-color: var(--md-sys-color-success);
  color: var(--md-sys-color-on-success);
  border: none;
  border-radius: 9999px;
  font-variation-settings: 'wght' 700, 'wdth' 108;
  cursor: pointer;
  transition: border-radius 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.15s ease;
}

.m3ex-btn-success:active:not(:disabled) {
  border-radius: 18px;
  transform: scale(0.97);
}

.m3ex-btn-success:disabled {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.62;
  cursor: not-allowed;
}

.m3ex-input {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  border: none;
  border-radius: 18px;
  width: 100%;
  transition: border-radius 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              background-color 0.2s ease;
}

.m3ex-input:focus {
  outline: none;
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-radius: 26px;
}

/* Floating Split-Pill Bar */
.m3ex-floating-bar {
  background-color: var(--md-sys-color-surface-container-highest);
  border: none;
  border-radius: 9999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.m3ex-pill-tab {
  border-radius: 9999px;
  color: var(--md-sys-color-on-surface-variant);
  font-variation-settings: 'wght' 600, 'wdth' 100;
  transition: padding 0.38s var(--m3ex-spring-expressive),
              background-color 0.22s ease,
              color 0.22s ease,
              font-variation-settings 0.34s var(--m3ex-spring-expressive),
              transform 0.26s var(--m3ex-spring-expressive),
              opacity 0.2s ease;
}

.m3ex-pill-tab:active {
  transform: scale(0.92);
}

.m3ex-pill-tab.active {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-variation-settings: 'wght' 760, 'wdth' 114;
}

/* Book Anatomy Interactive Row */
.part-row {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border: none;
  border-radius: 20px;
  transition: border-radius 0.38s var(--m3ex-spring-expressive),
              background-color 0.22s ease,
              color 0.22s ease,
              transform 0.3s var(--m3ex-spring-expressive);
}

@media (hover: hover) {
  .part-row:hover {
    transform: translateY(-2px);
  }
}

.part-row:active {
  transform: scale(0.98);
}

.part-row.active-part {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-radius: 30px;
  transform: translateY(-2px);
}

/* M3 Expressive Select Dropdown */
.m3ex-select-wrap {
  position: relative;
}

.m3ex-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  border: none;
  border-radius: 20px;
  width: 100%;
  font-variation-settings: 'wght' 650, 'wdth' 105;
  cursor: pointer;
  transition: border-radius 0.3s var(--m3ex-spring-expressive),
              background-color 0.2s ease,
              transform 0.24s var(--m3ex-spring-expressive);
}

.m3ex-select:focus {
  outline: none;
  border-radius: 28px;
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.m3ex-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
