/* ═══════════════════════════════════════════════════════════════════════════
 * M3E Component Styles
 * Phase 3: Core Component Library
 *
 * Depends on (load first): tokens.css, typography.css, shapes.css,
 *                          motion.css, elevation.css, layout.css
 *
 * Naming: BEM with m3e- prefix (e.g. .m3e-button--filled)
 * Tokens: Only --md-sys-* custom properties. Zero hardcoded colours.
 * ═══════════════════════════════════════════════════════════════════════════ */


/* ── Shared: State Layer ────────────────────────────────────────────────── */
/*
 * Applied to all interactive components via ::before pseudo-element.
 * The container must have position:relative and overflow:hidden.
 */
.m3e-state-layer {
  position: relative;
  overflow: hidden;
}
.m3e-state-layer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-state-layer:hover::before       { opacity: 0.08; }
.m3e-state-layer:focus-visible::before { opacity: 0.12; }
.m3e-state-layer:active::before      { opacity: 0.16; }
.m3e-state-layer[aria-disabled="true"]::before { display: none; }


/* ═══════════════════════════════════════════════════════════════════════════
 * DIVIDER
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-divider {
  border: none;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  margin: 0;
}
.m3e-divider--inset {
  margin-inline-start: var(--md-sys-spacing-4);
}
.m3e-divider--vertical {
  border-top: none;
  border-inline-start: 1px solid var(--md-sys-color-outline-variant);
  align-self: stretch;
  width: 0;
  height: auto;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * BADGE
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  vertical-align: middle;
}
/* Small dot badge (no count) */
.m3e-badge--small {
  width: 6px;
  height: 6px;
  min-width: 0;
  padding: 0;
}
/* Large badge (with count) */
.m3e-badge--large {
  height: 16px;
  min-width: 16px;
  padding: 0 4px;
}
.m3e-badge--primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.m3e-badge--secondary {
  background-color: var(--md-sys-color-secondary);
  color: var(--md-sys-color-on-secondary);
}
.m3e-badge--tertiary {
  background-color: var(--md-sys-color-tertiary);
  color: var(--md-sys-color-on-tertiary);
}
.m3e-badge--tertiary-container {
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
}
.m3e-badge--primary-container {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
.m3e-badge--error-container {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}
.m3e-badge--secondary-container {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.m3e-badge--neutral {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
}


/* ═══════════════════════════════════════════════════════════════════════════
 * BUTTON
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-button {
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--md-sys-spacing-2);
  /* Touch target */
  min-height: var(--md-sys-density-touch-target-default);
  padding: 0 var(--md-sys-spacing-6);
  /* Shape */
  border-radius: var(--md-sys-shape-corner-full);
  /* Typography */
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  /* Interactive */
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: none;
  outline: none;
  transition:
    box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-expressive-spatial-default),
    background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default),
    transform var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-expressive-spatial-fast);
}
.m3e-button:active {
  transform: scale(0.96);
}
.m3e-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-button:hover::before        { opacity: 0.08; }
.m3e-button:focus-visible::before { opacity: 0.12; }
.m3e-button:active::before       { opacity: 0.16; }
.m3e-button:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* Filled */
.m3e-button--filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-0);
}
.m3e-button--filled:hover { box-shadow: var(--md-sys-elevation-1); }

/* Tonal */
.m3e-button--tonal {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

/* Outlined */
.m3e-button--outlined {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}
.m3e-button--outlined:focus-visible { border-color: var(--md-sys-color-primary); }

/* Elevated */
.m3e-button--elevated {
  background-color: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-1);
}
.m3e-button--elevated:hover { box-shadow: var(--md-sys-elevation-2); }

/* Text */
.m3e-button--text {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  padding: 0 var(--md-sys-spacing-3);
}

/* Error tone — overrides color for any variant */
.m3e-button--error { color: var(--md-sys-color-error); }
.m3e-button--error.m3e-button--outlined { border-color: var(--md-sys-color-error); }
.m3e-button--error.m3e-button--filled {
  background-color: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
}
.m3e-button--error:focus-visible { outline-color: var(--md-sys-color-error); }

/* Sizes */
.m3e-button--sm {
  min-height: var(--md-sys-density-touch-target-compact);
  font-size: 12px;
  padding: 0 var(--md-sys-spacing-3);
}
.m3e-button--lg {
  min-height: 56px;
  font-size: 16px;
  padding: 0 var(--md-sys-spacing-8);
}
.m3e-button--xl {
  min-height: 64px;
  font-size: 18px;
  padding: 0 var(--md-sys-spacing-10);
}

/* Disabled */
.m3e-button[aria-disabled="true"],
.m3e-button:disabled {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent) !important;
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent) !important;
  border-color: transparent !important;
  box-shadow: none !important;
  cursor: not-allowed;
}
.m3e-button[aria-disabled="true"]::before,
.m3e-button:disabled::before { display: none; }

/* Loading state */
.m3e-button--loading {
  cursor: wait;
  pointer-events: none;
}
.m3e-button__icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}
.m3e-button__icon svg { width: 100%; height: 100%; }

/* Loading spinner */
.m3e-button__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: m3e-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes m3e-spin {
  to { transform: rotate(360deg); }
}

/* Disclosure trigger — full-width tonal button for expand/collapse panels */
.m3e-disclosure-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--md-sys-spacing-3);
  min-height: var(--md-sys-density-touch-target-default);
  padding: 0 var(--md-sys-spacing-5);
  border-radius: var(--md-sys-shape-corner-xl);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  border: none;
  position: relative;
  overflow: hidden;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  transition: background var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-disclosure-trigger::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default);
  pointer-events: none;
}
.m3e-disclosure-trigger:hover::before { opacity: 0.08; }
.m3e-disclosure-trigger:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.m3e-disclosure-trigger:active { transform: scale(0.98); }
.m3e-disclosure-trigger[aria-expanded="true"] {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-xl) var(--md-sys-shape-corner-xl) 0 0;
}
.m3e-disclosure-trigger .toggle-chevron {
  transition: transform var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-expressive-spatial-default);
}
.m3e-disclosure-trigger[aria-expanded="true"] .toggle-chevron {
  transform: rotate(180deg);
}


/* ═══════════════════════════════════════════════════════════════════════════
 * CHECKBOX
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-spacing-3);
  cursor: pointer;
  position: relative;
}
.m3e-checkbox__input {
  /* Reset and size */
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  background-color: transparent;
  cursor: pointer;
  position: relative;
  transition:
    border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default),
    background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-checkbox__input:checked {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}
.m3e-checkbox__input:checked::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 5px;
  height: 10px;
  border: 2px solid var(--md-sys-color-on-primary);
  border-top: none;
  border-left: none;
  transform-origin: center;
  transform: rotate(45deg);
}
.m3e-checkbox__input:indeterminate {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}
.m3e-checkbox__input:indeterminate::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 2px;
  background-color: var(--md-sys-color-on-primary);
}
.m3e-checkbox__input:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.m3e-checkbox__input:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.m3e-checkbox__label {
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
  user-select: none;
}
/* Touch target: state ripple on label */
.m3e-checkbox::before {
  content: '';
  position: absolute;
  inset: -10px -10px -10px -10px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-checkbox:hover::before { opacity: 0.08; }


/* ═══════════════════════════════════════════════════════════════════════════
 * RADIO
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-radio {
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-spacing-3);
  cursor: pointer;
}
.m3e-radio__input {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid var(--md-sys-color-outline);
  border-radius: 50%;
  background-color: transparent;
  cursor: pointer;
  position: relative;
  transition:
    border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-radio__input:checked {
  border-color: var(--md-sys-color-primary);
}
.m3e-radio__input:checked::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
}
.m3e-radio__input:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.m3e-radio__input:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.m3e-radio__label {
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
  user-select: none;
}
.m3e-radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-spacing-2);
}


/* ═══════════════════════════════════════════════════════════════════════════
 * SWITCH
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-spacing-3);
  cursor: pointer;
}
.m3e-switch--label-start { flex-direction: row-reverse; }
.m3e-switch__input {
  /* Hide the native input; state is reflected on __track */
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.m3e-switch__track {
  position: relative;
  width: 52px;
  height: 32px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-variant);
  border: 2px solid var(--md-sys-color-outline);
  transition:
    background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default),
    border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default);
  flex-shrink: 0;
  cursor: pointer;
}
.m3e-switch__input:checked ~ .m3e-switch__track,
.m3e-switch__input:checked + .m3e-switch__track {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}
.m3e-switch__thumb {
  position: absolute;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--md-sys-color-outline);
  transition:
    transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-expressive-spatial-default),
    width var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-expressive-spatial-default),
    height var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-expressive-spatial-default),
    background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-switch__input:checked ~ .m3e-switch__track .m3e-switch__thumb,
.m3e-switch__input:checked + .m3e-switch__track .m3e-switch__thumb {
  transform: translateY(-50%) translateX(20px);
  background-color: var(--md-sys-color-on-primary);
  width: 24px;
  height: 24px;
}
.m3e-switch__track:active .m3e-switch__thumb {
  width: 28px;
  height: 28px;
}
.m3e-switch__input:focus-visible ~ .m3e-switch__track,
.m3e-switch__input:focus-visible + .m3e-switch__track {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.m3e-switch__input:disabled ~ .m3e-switch__track,
.m3e-switch__input:disabled + .m3e-switch__track {
  opacity: 0.38;
  cursor: not-allowed;
}
.m3e-switch__label {
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
  user-select: none;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * PROGRESS INDICATOR
 * ═══════════════════════════════════════════════════════════════════════════ */

/* ── Linear ── */
.m3e-progress--linear {
  width: 100%;
  height: 4px;
  background-color: color-mix(in srgb, var(--md-sys-color-primary) 20%, transparent);
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
  position: relative;
}
.m3e-progress--linear .m3e-progress__bar {
  position: absolute;
  inset-block: 0;
  left: 0;
  background-color: var(--md-sys-color-primary);
  border-radius: inherit;
  transition: width var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard-effects-default);
}
/* Indeterminate linear */
.m3e-progress--linear.m3e-progress--indeterminate .m3e-progress__bar {
  width: 40% !important;
  animation: m3e-linear-indeterminate var(--md-sys-motion-duration-extra-long2) linear infinite;
}
@keyframes m3e-linear-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ── Circular ── */
.m3e-progress--circular {
  display: inline-block;
  position: relative;
}
.m3e-progress--circular svg {
  transform: rotate(-90deg);
}
.m3e-progress--circular .m3e-progress__track {
  fill: none;
  stroke: color-mix(in srgb, var(--md-sys-color-primary) 20%, transparent);
}
.m3e-progress--circular .m3e-progress__arc {
  fill: none;
  stroke: var(--md-sys-color-primary);
  stroke-linecap: round;
  transition: stroke-dashoffset var(--md-sys-motion-duration-medium2)
              var(--md-sys-motion-easing-standard-effects-default);
}
/* Indeterminate circular */
.m3e-progress--circular.m3e-progress--indeterminate .m3e-progress__arc {
  animation: m3e-circular-indeterminate 1.4s linear infinite;
}
@keyframes m3e-circular-indeterminate {
  0%   { stroke-dashoffset: 80; }
  50%  { stroke-dashoffset: 20; transform: rotate(135deg); }
  100% { stroke-dashoffset: 80; transform: rotate(360deg); }
}
/* Sizes */
.m3e-progress--circular.m3e-progress--sm  { width: 24px; height: 24px; }
.m3e-progress--circular.m3e-progress--md  { width: 40px; height: 40px; }
.m3e-progress--circular.m3e-progress--lg  { width: 56px; height: 56px; }

/* Color variants */
.m3e-progress--secondary .m3e-progress__bar,
.m3e-progress--secondary .m3e-progress__arc {
  stroke: var(--md-sys-color-secondary);
  background-color: var(--md-sys-color-secondary);
}
.m3e-progress--tertiary .m3e-progress__bar,
.m3e-progress--tertiary .m3e-progress__arc {
  stroke: var(--md-sys-color-tertiary);
  background-color: var(--md-sys-color-tertiary);
}

/* Circular — determinate dashoffset via CSS custom property */
.m3e-progress--circular:not(.m3e-progress--indeterminate) .m3e-progress__arc {
  stroke-dashoffset: calc(100.531 * (1 - var(--progress, 0) / 100));
}

/* ── Wavy linear — M3E expressive traveling wave ── */
.m3e-progress--wavy {
  height: 8px;
}
.m3e-progress--wavy .m3e-progress__bar {
  animation: m3e-wavy-wave 1.5s var(--md-sys-motion-easing-expressive-spatial-default) infinite;
}
.m3e-progress--wavy.m3e-progress--indeterminate .m3e-progress__bar {
  width: 40% !important;
  animation:
    m3e-linear-indeterminate var(--md-sys-motion-duration-extra-long2) linear infinite,
    m3e-wavy-wave 1.5s var(--md-sys-motion-easing-expressive-spatial-default) infinite;
}
/* Two full sine-wave cycles across the bar; the 50% keyframe shifts the
   wave by half a wavelength so linear interpolation creates a traveling
   wave effect.  17 polygon points keep the curve smooth at small sizes. */
@keyframes m3e-wavy-wave {
  0%, 100% {
    clip-path: polygon(
      0% 50%, 6% 82%, 12% 95%, 19% 82%, 25% 50%, 31% 18%, 38% 5%, 44% 18%,
      50% 50%, 56% 82%, 62% 95%, 69% 82%, 75% 50%, 81% 18%, 88% 5%, 94% 18%,
      100% 50%, 100% 100%, 0% 100%
    );
  }
  50% {
    clip-path: polygon(
      0% 50%, 6% 18%, 12% 5%, 19% 18%, 25% 50%, 31% 82%, 38% 95%, 44% 82%,
      50% 50%, 56% 18%, 62% 5%, 69% 18%, 75% 50%, 81% 82%, 88% 95%, 94% 82%,
      100% 50%, 100% 100%, 0% 100%
    );
  }
}

/* ── M3E shape-morphing loading indicator ── */
.m3e-loading-indicator {
  width: 48px;
  height: 48px;
  background-color: var(--md-sys-color-primary);
  animation:
    m3e-loading-morph 2s var(--md-sys-motion-easing-expressive-spatial-default) infinite,
    m3e-loading-hue 2s ease-in-out infinite;
}
.m3e-loading-indicator--secondary { background-color: var(--md-sys-color-secondary); }
.m3e-loading-indicator--tertiary  { background-color: var(--md-sys-color-tertiary); }
.m3e-loading-indicator--small { width: 24px; height: 24px; }
.m3e-loading-indicator--large { width: 64px; height: 64px; }
/* Inline variant for buttons — inherits text color, no hue shift */
.m3e-loading-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  border-radius: 50%;
  animation: m3e-loading-morph 1.5s var(--md-sys-motion-easing-expressive-spatial-default) infinite;
  vertical-align: middle;
}
/* 12-stop morph cycle — organic border-radius with smooth intermediate steps */
@keyframes m3e-loading-morph {
  0%      { border-radius: 50%;                                    transform: rotate(0deg)   scale(1); }
  8%      { border-radius: 45% 55% 55% 45% / 55% 45% 55% 45%;    transform: rotate(30deg)  scale(0.95); }
  16%     { border-radius: 40% 60% 60% 40% / 60% 40% 60% 40%;    transform: rotate(60deg)  scale(0.88); }
  25%     { border-radius: var(--md-sys-shape-corner-large);        transform: rotate(90deg)  scale(0.85); }
  33%     { border-radius: 55% 45% 45% 55% / 45% 55% 45% 55%;    transform: rotate(120deg) scale(0.88); }
  42%     { border-radius: 60% 40% 40% 60% / 40% 60% 40% 60%;    transform: rotate(150deg) scale(0.92); }
  50%     { border-radius: 50% 50% 50% 12%;                        transform: rotate(180deg) scale(1); }
  58%     { border-radius: 45% 55% 45% 55% / 55% 45% 55% 45%;    transform: rotate(210deg) scale(0.95); }
  66%     { border-radius: 40% 60% 50% 50% / 50% 40% 60% 50%;    transform: rotate(240deg) scale(0.85); }
  75%     { border-radius: var(--md-sys-shape-corner-medium);       transform: rotate(270deg) scale(0.85); }
  83%     { border-radius: 48% 52% 55% 45% / 52% 48% 45% 55%;    transform: rotate(300deg) scale(0.90); }
  92%     { border-radius: 50% 40% 60% 50% / 60% 50% 40% 50%;    transform: rotate(330deg) scale(0.95); }
  100%    { border-radius: 50%;                                    transform: rotate(360deg) scale(1); }
}
/* Subtle hue shift across the morph cycle (standalone indicator only, not inline) */
@keyframes m3e-loading-hue {
  0%, 100% { filter: hue-rotate(0deg); }
  50%      { filter: hue-rotate(18deg); }
}
/* Pull-to-refresh M3E indicator */
.m3e-pull-indicator {
  border-radius: 50%;
  will-change: border-radius, transform;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * CHIP
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-spacing-2);
  height: 32px;
  padding: 0 var(--md-sys-spacing-4);
  border-radius: var(--md-sys-shape-corner-small);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  transition:
    background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default),
    border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default);
  user-select: none;
  border: none;
  outline: none;
  /* State layer */
}
.m3e-chip::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-chip:hover::before        { opacity: 0.08; }
.m3e-chip:focus-visible::before { opacity: 0.12; }
.m3e-chip:active::before       { opacity: 0.16; }

/* Assist chip (default) */
.m3e-chip--assist {
  background-color: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline);
}

/* Elevated chip — shadow replaces outline border */
.m3e-chip--elevated {
  border-color: transparent !important;
  box-shadow: var(--md-sys-elevation-1);
}
.m3e-chip--elevated:hover { box-shadow: var(--md-sys-elevation-2); }

/* Filter chip */
.m3e-chip--filter {
  background-color: transparent;
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline);
}
.m3e-chip--filter[aria-pressed="true"],
.m3e-chip--filter.m3e-chip--selected {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

/* Input chip */
.m3e-chip--input {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline);
}

/* Suggestion chip */
.m3e-chip--suggestion {
  background-color: transparent;
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.m3e-chip:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 1px;
}
.m3e-chip[aria-disabled="true"] {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}
.m3e-chip__icon,
.m3e-chip__trailing-icon {
  display: flex;
  align-items: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.m3e-chip__icon svg,
.m3e-chip__trailing-icon svg { width: 100%; height: 100%; }
.m3e-chip__trailing-icon { cursor: pointer; }

/* Chip label reset — for input-variant group structure (div[role="group"]) */
.m3e-chip__label {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: inherit;
}
/* Trailing icon button inside group — reset and add own interaction */
.m3e-chip[role="group"] .m3e-chip__trailing-icon {
  background: none;
  border: none;
  padding: var(--md-sys-spacing-1);
  margin-inline-end: calc(-1 * var(--md-sys-spacing-2));
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface-variant);
  position: relative;
  overflow: hidden;
}
.m3e-chip[role="group"] .m3e-chip__trailing-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
}
.m3e-chip[role="group"] .m3e-chip__trailing-icon:hover::before { opacity: 0.08; }
.m3e-chip[role="group"] .m3e-chip__trailing-icon:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 1px;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * CARD
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-card {
  border-radius: var(--md-sys-shape-corner-large);
  overflow: hidden;
  position: relative;
  transition:
    box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-expressive-spatial-default);
}
/* Elevated */
.m3e-card--elevated {
  background-color: var(--md-sys-color-surface-container-low);
  box-shadow: var(--md-sys-elevation-1);
}
.m3e-card--elevated:hover { box-shadow: var(--md-sys-elevation-2); }
/* Filled */
.m3e-card--filled {
  background-color: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-sys-elevation-0);
}
/* Outlined */
.m3e-card--outlined {
  background-color: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-0);
}

/* Interactive card (link or button) */
.m3e-card[href],
.m3e-card--interactive {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.m3e-card[href]::before,
.m3e-card--interactive::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-sys-color-on-surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-card[href]:hover::before,
.m3e-card--interactive:hover::before    { opacity: 0.08; }
.m3e-card[href]:focus-visible::before,
.m3e-card--interactive:focus-visible::before { opacity: 0.12; }
.m3e-card[href]:focus-visible,
.m3e-card--interactive:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
/* Hover-lift spring (hover-capable devices only to avoid sticky touch hover) */
@media (hover: hover) {
  .m3e-card[href],
  .m3e-card--interactive {
    transition:
      transform var(--md-sys-motion-duration-short4)
                var(--md-sys-motion-easing-expressive-spatial-default),
      box-shadow var(--md-sys-motion-duration-short4)
                var(--md-sys-motion-easing-standard-effects-default);
  }
  .m3e-card[href]:hover,
  .m3e-card--interactive:hover {
    transform: translateY(-3px) scale(1.005);
    box-shadow: var(--md-sys-elevation-3);
  }
}

/* Card slots */
.m3e-card__media {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}
.m3e-card__content {
  padding: var(--md-sys-spacing-4);
}
.m3e-card__actions {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-2);
  padding: var(--md-sys-spacing-2) var(--md-sys-spacing-4) var(--md-sys-spacing-4);
}
.m3e-card__headline {
  font-size: 16px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  margin: 0 0 var(--md-sys-spacing-2);
}
.m3e-card__subhead {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 var(--md-sys-spacing-2);
}
.m3e-card__supporting {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0;
}

/* Card entrance animation (staggered) */
.m3e-card--animate-in {
  opacity: 0;
  transform: translateY(12px);
  animation: m3e-card-enter var(--md-sys-motion-duration-medium2)
             var(--md-sys-motion-easing-expressive-spatial-default)
             calc(var(--card-index, 0) * 60ms) forwards;
}
@keyframes m3e-card-enter {
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .m3e-card--animate-in {
    opacity: 1;
    transform: none;
    animation: none;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
 * LIST
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-list {
  list-style: none;
  margin: 0;
  padding: var(--md-sys-spacing-2) 0;
}
.m3e-list--containerised {
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
}
.m3e-list__item {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-4);
  min-height: var(--md-sys-density-touch-target-default);
  padding: var(--md-sys-spacing-2) var(--md-sys-spacing-4);
  position: relative;
  overflow: hidden;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  transition: background-color var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-list__item[href] { cursor: pointer; }
.m3e-list__item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-sys-color-on-surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-list__item[href]:hover::before    { opacity: 0.08; }
.m3e-list__item[href]:focus-visible::before { opacity: 0.12; }
.m3e-list__item[href]:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 3px var(--md-sys-color-primary);
}

/* Leading slot */
.m3e-list__leading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.m3e-list__leading-icon {
  width: 24px;
  height: 24px;
  color: var(--md-sys-color-on-surface-variant);
}
.m3e-list__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
}

/* Content */
.m3e-list__content {
  flex: 1;
  min-width: 0;
}
.m3e-list__overline {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
}
.m3e-list__headline {
  font-size: 16px;
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m3e-list__supporting {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}
.m3e-list__item--two-line .m3e-list__supporting { -webkit-line-clamp: 1; }
.m3e-list__item--three-line .m3e-list__supporting { -webkit-line-clamp: 2; }

/* Trailing slot */
.m3e-list__trailing {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-2);
  flex-shrink: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
}
.m3e-list__trailing-icon {
  width: 24px;
  height: 24px;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * TABLE
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-table-wrapper {
  width: 100%;
  overflow-x: auto;
}
.m3e-table-wrapper--containerised {
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
}
.m3e-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
}
.m3e-table th {
  text-align: start;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.1px;
  color: var(--md-sys-color-on-surface-variant);
  padding: var(--md-sys-spacing-3) var(--md-sys-spacing-4);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  white-space: nowrap;
}
.m3e-table th.m3e-table__th--numeric { text-align: end; }
.m3e-table__sort-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-spacing-1);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  padding: 0;
}
.m3e-table__sort-btn:hover { color: var(--md-sys-color-on-surface); }
.m3e-table__sort-icon {
  width: 16px;
  height: 16px;
  opacity: 0.4;
  transition: opacity var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-table__sort-btn[aria-sort] .m3e-table__sort-icon { opacity: 1; }
.m3e-table td {
  padding: var(--md-sys-spacing-3) var(--md-sys-spacing-4);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  vertical-align: middle;
}
.m3e-table td.m3e-table__td--numeric { text-align: end; }
.m3e-table tbody tr {
  transition: background-color var(--md-sys-motion-duration-short1)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-table tbody tr:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}
.m3e-table tbody tr:last-child td { border-bottom: none; }
.m3e-table__empty {
  text-align: center;
  padding: var(--md-sys-spacing-8);
  color: var(--md-sys-color-on-surface-variant);
  font-style: italic;
}

/* Striped variant */
.m3e-table--striped tbody tr:nth-child(even) {
  background-color: color-mix(in srgb, var(--md-sys-color-surface-container-low) 50%, transparent);
}

/* Dense variant */
.m3e-table--dense th,
.m3e-table--dense td {
  padding: var(--md-sys-spacing-2) var(--md-sys-spacing-3);
}

/* Sticky header */
.m3e-table--sticky-header th {
  position: sticky;
  top: 0;
  background-color: var(--md-sys-color-surface-container-high);
  z-index: 1;
}

/* Containerised table (elevated wrapper) */
.m3e-table-wrapper--elevated {
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-1);
  overflow: hidden;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * TEXT FIELD
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-text-field {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-spacing-1);
  position: relative;
}

/* ── Outlined variant ── */
.m3e-text-field--outlined .m3e-text-field__label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 2px;
  transition: color var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-text-field--outlined .m3e-text-field__input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-3);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  background-color: transparent;
  padding: 0 var(--md-sys-spacing-4);
  min-height: 56px;
  transition:
    border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default),
    box-shadow var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-text-field--outlined .m3e-text-field__input-wrapper:focus-within {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
  box-shadow: none;
}
.m3e-text-field--outlined.m3e-text-field--error .m3e-text-field__input-wrapper {
  border-color: var(--md-sys-color-error);
}
.m3e-text-field--outlined.m3e-text-field--error .m3e-text-field__input-wrapper:focus-within {
  border-color: var(--md-sys-color-error);
}

/* ── Filled variant ── */
.m3e-text-field--filled .m3e-text-field__label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 2px;
}
.m3e-text-field--filled .m3e-text-field__input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-3);
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-small) 0 0;
  border-bottom: 1px solid var(--md-sys-color-outline);
  padding: 0 var(--md-sys-spacing-4);
  min-height: 56px;
  transition:
    border-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-text-field--filled .m3e-text-field__input-wrapper:focus-within {
  border-bottom: 2px solid var(--md-sys-color-primary);
}
.m3e-text-field--filled.m3e-text-field--error .m3e-text-field__input-wrapper {
  border-bottom-color: var(--md-sys-color-error);
}

/* ── Input override: reset _style_form_fields() Tailwind classes ── */
/* Scoped strictly to inputs inside an m3e text field wrapper */
.m3e-text-field__input-wrapper > input,
.m3e-text-field__input-wrapper > textarea,
.m3e-text-field__input-wrapper > select {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  padding: var(--md-sys-spacing-4) 0 !important;
  width: 100% !important;
  flex: 1;
  min-width: 0;
  color: var(--md-sys-color-on-surface) !important;
  font-size: 16px !important;
  font-family: inherit !important;
  ring-offset-width: 0 !important;
  /* Override Tailwind focus ring */
  --tw-ring-shadow: none !important;
  --tw-ring-offset-shadow: none !important;
}
.m3e-text-field__input-wrapper > input,
.m3e-text-field__input-wrapper > textarea,
.m3e-text-field__input-wrapper > select {
  background: transparent !important;
}
/* Dark mode: force explicit surface on <select> since browsers ignore transparent */
.dark .m3e-text-field__input-wrapper > select,
[data-theme="dark"] .m3e-text-field__input-wrapper > select {
  background-color: var(--md-sys-color-surface-container-highest) !important;
}
.m3e-text-field__input-wrapper > select {
  cursor: pointer;
  padding-right: 2.5rem !important;
}
.m3e-text-field__input-wrapper > textarea {
  resize: vertical;
  min-height: 80px;
}

/* Icons */
.m3e-text-field__icon {
  display: flex;
  align-items: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--md-sys-color-on-surface-variant);
}
.m3e-text-field__icon svg { width: 100%; height: 100%; }
.m3e-text-field--error .m3e-text-field__icon--trailing {
  color: var(--md-sys-color-error);
}

/* Helper / error / hint text */
.m3e-text-field__helper-text {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  padding-inline: var(--md-sys-spacing-4);
}
.m3e-text-field__error-text {
  font-size: 12px;
  color: var(--md-sys-color-error);
  padding-inline: var(--md-sys-spacing-4);
}
/* Required marker */
.m3e-text-field__label .m3e-required { color: var(--md-sys-color-error); }

/* Error label colour */
.m3e-text-field--error .m3e-text-field__label { color: var(--md-sys-color-error); }


/* ═══════════════════════════════════════════════════════════════════════════
 * TOOLBAR
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-toolbar {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-2);
  padding: var(--md-sys-spacing-2) var(--md-sys-spacing-4);
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-full);
}
.m3e-toolbar--floating {
  box-shadow: var(--md-sys-elevation-3);
}
.m3e-toolbar--docked {
  border-radius: 0;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
.m3e-toolbar__action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--md-sys-density-touch-target-default);
  height: var(--md-sys-density-touch-target-default);
  border-radius: var(--md-sys-shape-corner-full);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  position: relative;
  overflow: hidden;
  transition: color var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
  flex-shrink: 0;
  text-decoration: none;
}
.m3e-toolbar__action::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
}
.m3e-toolbar__action:hover::before        { opacity: 0.08; }
.m3e-toolbar__action:focus-visible::before { opacity: 0.12; }
.m3e-toolbar__action:active::before       { opacity: 0.16; }
.m3e-toolbar__action:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.m3e-toolbar__action--active { color: var(--md-sys-color-primary); }
.m3e-toolbar__action[aria-disabled="true"] { opacity: 0.38; cursor: not-allowed; pointer-events: none; }
.m3e-toolbar__action svg { width: 24px; height: 24px; }
.m3e-toolbar__divider {
  width: 1px;
  height: 24px;
  background-color: var(--md-sys-color-outline-variant);
  margin-inline: var(--md-sys-spacing-2);
  flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * NAVIGATION BAR (bottom, mobile)
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background-color: var(--md-sys-color-surface-container);
  border-top: 1px solid var(--md-sys-color-outline-variant);
  padding-block: var(--md-sys-spacing-2);
  padding-bottom: max(var(--md-sys-spacing-2), env(safe-area-inset-bottom, 0px));
}
/* Ensure .hidden beats display:flex even when Tailwind utilities are in a lower-priority layer */
.m3e-nav-bar.hidden { display: none; }
.m3e-nav-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--md-sys-spacing-1);
  min-width: 48px;
  padding: var(--md-sys-spacing-1) var(--md-sys-spacing-3);
  text-decoration: none;
  color: var(--md-sys-color-on-surface-variant);
  position: relative;
  transition: color var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-nav-bar__item--active { color: var(--md-sys-color-on-secondary-container); }
.m3e-nav-bar__indicator {
  width: 64px;
  height: 32px;
  border-radius: var(--md-sys-shape-corner-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  transition:
    background-color var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-expressive-spatial-default),
    width var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-expressive-spatial-default);
  position: relative;
}
.m3e-nav-bar__item--active .m3e-nav-bar__indicator {
  background-color: var(--md-sys-color-secondary-container);
}
.m3e-nav-bar__icon {
  width: 24px;
  height: 24px;
}
.m3e-nav-bar__label {
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * NAVIGATION RAIL (sidebar, desktop)
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-nav-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--md-sys-spacing-1);
  width: 80px;
  padding: var(--md-sys-spacing-4) 0;
  background-color: var(--md-sys-color-surface-container-low);
  transition: width var(--md-sys-motion-duration-medium2)
              var(--md-sys-motion-easing-expressive-spatial-default);
  overflow: hidden;
}
.m3e-nav-rail--expanded { width: 256px; align-items: flex-start; }
.m3e-nav-rail__fab {
  margin-bottom: var(--md-sys-spacing-4);
  align-self: center;
}
.m3e-nav-rail__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--md-sys-spacing-1);
  padding: var(--md-sys-spacing-1) 0;
  width: 100%;
  text-decoration: none;
  color: var(--md-sys-color-on-surface-variant);
  position: relative;
}
.m3e-nav-rail--expanded .m3e-nav-rail__item {
  flex-direction: row;
  gap: var(--md-sys-spacing-3);
  padding: var(--md-sys-spacing-1) var(--md-sys-spacing-4);
}
.m3e-nav-rail__item--active { color: var(--md-sys-color-on-secondary-container); }
.m3e-nav-rail__indicator {
  width: 56px;
  height: 32px;
  border-radius: var(--md-sys-shape-corner-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  transition: background-color var(--md-sys-motion-duration-medium2)
              var(--md-sys-motion-easing-expressive-spatial-default);
}
.m3e-nav-rail--expanded .m3e-nav-rail__indicator {
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
}
.m3e-nav-rail__item--active .m3e-nav-rail__indicator {
  background-color: var(--md-sys-color-secondary-container);
}
.m3e-nav-rail__icon { width: 24px; height: 24px; flex-shrink: 0; }
.m3e-nav-rail__label {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  max-width: 0;
  transition: max-width var(--md-sys-motion-duration-medium2)
              var(--md-sys-motion-easing-expressive-spatial-default);
}
.m3e-nav-rail--expanded .m3e-nav-rail__label { max-width: 160px; }
.m3e-nav-rail__collapse-btn {
  margin-top: auto;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * NAVIGATION DRAWER
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-nav-drawer {
  display: flex;
  flex-direction: column;
  width: 360px;
  max-width: 90vw;
  height: 100%;
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: 0 var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.m3e-nav-drawer--permanent { border-radius: 0; }
.m3e-nav-drawer__headline {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  padding: var(--md-sys-spacing-4) var(--md-sys-spacing-6) var(--md-sys-spacing-2);
}
.m3e-nav-drawer__item {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-3);
  height: 56px;
  padding: 0 var(--md-sys-spacing-4);
  border-radius: var(--md-sys-shape-corner-full);
  margin: 2px var(--md-sys-spacing-3);
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  position: relative;
  overflow: hidden;
  transition: background-color var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-nav-drawer__item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
}
.m3e-nav-drawer__item:hover::before        { opacity: 0.08; }
.m3e-nav-drawer__item:focus-visible::before { opacity: 0.12; }
.m3e-nav-drawer__item:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: -3px;
}
.m3e-nav-drawer__item--active {
  position: relative;
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.m3e-nav-drawer__item--active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 0 var(--md-sys-shape-corner-full) var(--md-sys-shape-corner-full) 0;
  background: var(--md-sys-color-primary);
}
.m3e-nav-drawer__item-icon { width: 24px; height: 24px; flex-shrink: 0; }
.m3e-nav-drawer__item-label {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.m3e-nav-drawer__section-header {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
  padding: var(--md-sys-spacing-4) var(--md-sys-spacing-6) var(--md-sys-spacing-2);
}
.m3e-nav-drawer__section-header:not(:first-child) {
  margin-top: var(--md-sys-spacing-2);
  padding-top: var(--md-sys-spacing-4);
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* ── Modal drawer: scrim + slide-in ── */
.m3e-nav-drawer-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent);
  z-index: 1200;
  align-items: stretch;
}
.m3e-nav-drawer-scrim[data-m3e-open] { display: flex; }
.m3e-nav-drawer--modal {
  border-radius: 0 var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) 0;
  animation: m3e-drawer-enter var(--md-sys-motion-duration-medium3)
             var(--md-sys-motion-easing-expressive-spatial-default);
  pointer-events: auto;
}
@keyframes m3e-drawer-enter {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}
.m3e-nav-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--md-sys-spacing-2) var(--md-sys-spacing-3) 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * TOP APP BAR
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-top-app-bar {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-1);
  height: 64px;
  padding: 0 var(--md-sys-spacing-1);
  background-color: var(--md-sys-color-surface);
  transition:
    background-color var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard-effects-default),
    box-shadow var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-top-app-bar--fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
}
.m3e-top-app-bar--scrolled {
  background-color: var(--md-sys-color-surface-container);
  box-shadow: var(--md-sys-elevation-2);
}
.m3e-top-app-bar__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--md-sys-density-touch-target-default);
  height: var(--md-sys-density-touch-target-default);
  border-radius: var(--md-sys-shape-corner-full);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  text-decoration: none;
}
.m3e-top-app-bar__icon-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
}
.m3e-top-app-bar__icon-btn:hover::before        { opacity: 0.08; }
.m3e-top-app-bar__icon-btn:focus-visible::before { opacity: 0.12; }
.m3e-top-app-bar__icon-btn:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.m3e-top-app-bar__icon-btn svg { width: 24px; height: 24px; }
.m3e-top-app-bar__title {
  flex: 1;
  font-size: 22px;
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
  padding: 0 var(--md-sys-spacing-3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.m3e-top-app-bar__actions {
  display: flex;
  align-items: center;
}
/* Embedded search bar in top app bar */
.m3e-top-app-bar__search {
  flex: 1;
  box-shadow: none;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * SEARCH BAR
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-search-bar {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-2);
  height: 56px;
  padding: 0 var(--md-sys-spacing-4);
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--md-sys-elevation-1);
}
.m3e-search-bar__icon { width: 24px; height: 24px; flex-shrink: 0; color: var(--md-sys-color-on-surface); }
.m3e-search-bar__input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 16px;
  color: var(--md-sys-color-on-surface);
}
.m3e-search-bar__input::placeholder { color: var(--md-sys-color-on-surface-variant); }
.m3e-search-bar__trailing { width: 24px; height: 24px; flex-shrink: 0; color: var(--md-sys-color-on-surface-variant); }


/* ═══════════════════════════════════════════════════════════════════════════
 * TABS
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-tabs {
  position: relative;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.m3e-tabs__list {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  position: relative;
}
.m3e-tabs__list::-webkit-scrollbar { display: none; }
.m3e-tabs__tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--md-sys-spacing-1);
  min-width: 90px;
  height: 48px;
  padding: 0 var(--md-sys-spacing-4);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: color var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-tabs__tab::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-tabs__tab:hover::before        { opacity: 0.08; }
.m3e-tabs__tab:focus-visible::before { opacity: 0.12; }
.m3e-tabs__tab:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--md-sys-color-primary); }
.m3e-tabs__tab[aria-selected="true"] { color: var(--md-sys-color-primary); }
.m3e-tabs__tab-icon { width: 24px; height: 24px; flex-shrink: 0; }
.m3e-tabs__tab-label-row {
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-spacing-1);
}
.m3e-tabs__tab-label {
  line-height: 1;
}
.m3e-tabs__indicator {
  position: absolute;
  bottom: 0;
  height: 3px;
  background-color: var(--md-sys-color-primary);
  border-radius: 3px 3px 0 0;
  transition:
    left var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-expressive-spatial-default),
    width var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-expressive-spatial-default);
}
/* Secondary tabs */
.m3e-tabs--secondary .m3e-tabs__tab[aria-selected="true"] {
  color: var(--md-sys-color-on-surface);
}
.m3e-tabs--secondary .m3e-tabs__indicator {
  background-color: var(--md-sys-color-on-surface);
}
/* Tab panels */
.m3e-tabs__panel[hidden] { display: none; }
.m3e-tabs__panel { padding-block: var(--md-sys-spacing-4); }


/* ═══════════════════════════════════════════════════════════════════════════
 * MENU
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-menu {
  display: none;
  flex-direction: column;
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-extra-small);
  box-shadow: var(--md-sys-elevation-2);
  padding: var(--md-sys-spacing-2) 0;
  min-width: 112px;
  max-width: 280px;
  position: absolute;
  z-index: 1000;
  outline: none;
  /* Enter animation */
  transform-origin: top left;
  animation: m3e-menu-enter var(--md-sys-motion-duration-medium1)
             var(--md-sys-motion-easing-expressive-spatial-default);
}
.m3e-menu[data-m3e-open] { display: flex; }
@keyframes m3e-menu-enter {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}
.m3e-menu__item {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-3);
  height: var(--md-sys-density-touch-target-default);
  padding: 0 var(--md-sys-spacing-4);
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  background: none;
  border: none;
  text-align: start;
  text-decoration: none;
  width: 100%;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}
.m3e-menu__item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
}
.m3e-menu__item:hover::before        { opacity: 0.08; }
.m3e-menu__item:focus-visible::before { opacity: 0.12; }
.m3e-menu__item:focus-visible { outline: none; }
.m3e-menu__item--destructive { color: var(--md-sys-color-error); }
.m3e-menu__item[aria-disabled="true"] { opacity: 0.38; cursor: not-allowed; pointer-events: none; }
.m3e-menu__item-icon { width: 24px; height: 24px; flex-shrink: 0; color: var(--md-sys-color-on-surface-variant); }
.m3e-menu__item--destructive .m3e-menu__item-icon { color: var(--md-sys-color-error); }
.m3e-menu__divider {
  border: none;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  margin: var(--md-sys-spacing-2) 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * TOAST PILL (legacy glass-pill replacement)
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-toast-pill {
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  box-shadow: var(--md-sys-elevation-3);
}
.m3e-toast-pill svg { color: inherit; }


/* ═══════════════════════════════════════════════════════════════════════════
 * SNACKBAR
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-snackbar-container {
  position: fixed;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--md-sys-spacing-2);
  pointer-events: none;
}
.m3e-snackbar-container--bottom-center {
  bottom: max(var(--md-sys-spacing-6), env(safe-area-inset-bottom, 16px));
  left: 50%;
  transform: translateX(-50%);
}
/* Raise above mobile bottom nav bar (hidden at 840px) */
@media (max-width: 839px) {
  .m3e-snackbar-container--bottom-center {
    bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  }
}
.m3e-snackbar-container--bottom-start { bottom: var(--md-sys-spacing-6); left: var(--md-sys-spacing-6); }
.m3e-snackbar-container--bottom-end   { bottom: var(--md-sys-spacing-6); right: var(--md-sys-spacing-6); }
.m3e-snackbar {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-4);
  min-width: 288px;
  max-width: 568px;
  padding: var(--md-sys-spacing-3) var(--md-sys-spacing-4);
  background-color: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  border-radius: var(--md-sys-shape-corner-extra-small);
  box-shadow: var(--md-sys-elevation-3);
  pointer-events: auto;
  /* Enter */
  animation: m3e-snackbar-enter var(--md-sys-motion-duration-medium2)
             var(--md-sys-motion-easing-expressive-spatial-default);
}
.m3e-snackbar--exiting {
  animation: m3e-snackbar-exit var(--md-sys-motion-duration-medium1)
             var(--md-sys-motion-easing-standard-effects-default) forwards;
}
@keyframes m3e-snackbar-enter {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes m3e-snackbar-exit {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.m3e-snackbar__message {
  flex: 1;
  font-size: 14px;
  line-height: 20px;
}
.m3e-snackbar__action {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: var(--md-sys-color-inverse-primary);
  padding: 0;
  flex-shrink: 0;
  white-space: nowrap;
}
.m3e-snackbar__action:hover { opacity: 0.8; }


/* ═══════════════════════════════════════════════════════════════════════════
 * FAB (Floating Action Button)
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--md-sys-spacing-3);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  transition:
    box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-expressive-spatial-default),
    background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard-effects-default),
    transform var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-expressive-spatial-fast);
}
.m3e-fab:active {
  transform: scale(0.94);
}
.m3e-fab::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  pointer-events: none;
}
.m3e-fab:hover::before        { opacity: 0.08; }
.m3e-fab:focus-visible::before { opacity: 0.12; }
.m3e-fab:active::before       { opacity: 0.16; }
.m3e-fab:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* Sizes */
.m3e-fab--small {
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-3);
}
.m3e-fab--medium {
  width: 56px;
  height: 56px;
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--md-sys-elevation-3);
}
.m3e-fab--large {
  width: 96px;
  height: 96px;
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-3);
}
.m3e-fab--extended {
  height: 56px;
  padding: 0 var(--md-sys-spacing-5);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--md-sys-elevation-3);
  min-width: 80px;
}
.m3e-fab:hover { box-shadow: var(--md-sys-elevation-4); }

.m3e-fab__icon { width: 24px; height: 24px; flex-shrink: 0; }
.m3e-fab--small .m3e-fab__icon { width: 20px; height: 20px; }
.m3e-fab--large .m3e-fab__icon { width: 36px; height: 36px; }
.m3e-fab__label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  max-width: 200px;
  transition: max-width var(--md-sys-motion-duration-medium2)
              var(--md-sys-motion-easing-expressive-spatial-default);
}
.m3e-fab--extended.m3e-fab--collapsed .m3e-fab__label { max-width: 0; }

/* Color variants */
.m3e-fab--secondary {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.m3e-fab--tertiary {
  background-color: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
}
.m3e-fab--surface {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-primary);
}


/* ═══════════════════════════════════════════════════════════════════════════
 * DIALOG
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-dialog-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background-color: color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent);
  z-index: 1200;
  align-items: center;
  justify-content: center;
}
.m3e-dialog-scrim[data-m3e-open] { display: flex; }

.m3e-dialog {
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-extra-large);
  box-shadow: var(--md-sys-elevation-3);
  width: min(560px, calc(100vw - var(--md-sys-spacing-8)));
  max-height: min(560px, calc(100dvh - var(--md-sys-spacing-8)));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: m3e-dialog-enter var(--md-sys-motion-duration-medium3)
             var(--md-sys-motion-easing-expressive-spatial-default);
}
.m3e-dialog-scrim:not([data-m3e-open]) .m3e-dialog {
  animation: m3e-dialog-exit var(--md-sys-motion-duration-medium2)
             var(--md-sys-motion-easing-standard-effects-default);
}
@keyframes m3e-dialog-enter {
  from { opacity: 0; transform: scale(0.85) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes m3e-dialog-exit {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.m3e-dialog__header {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-spacing-2);
  padding: var(--md-sys-spacing-6) var(--md-sys-spacing-6) var(--md-sys-spacing-4);
}
.m3e-dialog__icon {
  width: 24px;
  height: 24px;
  color: var(--md-sys-color-secondary);
  margin-bottom: var(--md-sys-spacing-2);
}
.m3e-dialog__title {
  font-size: 24px;
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
  margin: 0;
}
.m3e-dialog__content {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--md-sys-spacing-6) var(--md-sys-spacing-4);
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 20px;
}
.m3e-dialog__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--md-sys-spacing-2);
  padding: var(--md-sys-spacing-3) var(--md-sys-spacing-6);
}

/* Full-screen variant */
.m3e-dialog--fullscreen {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  margin: 0;
}
.m3e-dialog--fullscreen .m3e-dialog__header {
  flex-direction: row;
  align-items: center;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  padding-block: var(--md-sys-spacing-3);
}
.m3e-dialog--fullscreen .m3e-dialog__title { flex: 1; font-size: 22px; }


/* ═══════════════════════════════════════════════════════════════════════════
 * BOTTOM SHEET
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-bottom-sheet-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background-color: color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent);
  z-index: 1100;
  align-items: flex-end;
}
.m3e-bottom-sheet-scrim[data-m3e-open] { display: flex; }
.m3e-bottom-sheet-scrim--standard {
  background-color: transparent;
  pointer-events: none;
}
.m3e-bottom-sheet-scrim--standard[data-m3e-open] { pointer-events: auto; }

.m3e-bottom-sheet {
  width: 100%;
  max-height: 90vh;
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  will-change: transform;
  animation: m3e-sheet-enter var(--md-sys-motion-duration-medium3)
             var(--md-sys-motion-easing-expressive-spatial-default);
  transition: transform var(--md-sys-motion-duration-medium2)
              var(--md-sys-motion-easing-expressive-spatial-default);
}
@keyframes m3e-sheet-enter {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.m3e-bottom-sheet--exiting {
  animation: m3e-sheet-exit var(--md-sys-motion-duration-medium2)
             var(--md-sys-motion-easing-standard-effects-default) forwards;
}
@keyframes m3e-sheet-exit {
  from { transform: translateY(0); }
  to   { transform: translateY(100%); }
}
.m3e-bottom-sheet__drag-handle-wrapper {
  display: flex;
  justify-content: center;
  padding: var(--md-sys-spacing-2) 0;
  cursor: grab;
}
.m3e-bottom-sheet__drag-handle-wrapper:active { cursor: grabbing; }
.m3e-bottom-sheet__drag-handle {
  background: none;
  border: none;
  padding: var(--md-sys-spacing-2) var(--md-sys-spacing-8);
  cursor: grab;
}
.m3e-bottom-sheet__drag-handle::after {
  content: '';
  display: block;
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background-color: var(--md-sys-color-on-surface-variant);
  opacity: 0.4;
}
.m3e-bottom-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--md-sys-spacing-3) var(--md-sys-spacing-6);
}
.m3e-bottom-sheet__title {
  font-size: 16px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}
.m3e-bottom-sheet__content {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--md-sys-spacing-6) var(--md-sys-spacing-6);
}
.m3e-bottom-sheet--full-height { max-height: 100vh; }


/* ═══════════════════════════════════════════════════════════════════════════
 * Shared: Scrim close button (data-m3e-trigger on scrim)
 * ═══════════════════════════════════════════════════════════════════════════ */

/* Scrim divs that are the trigger for closing an overlay */
.m3e-dialog-scrim[data-m3e-trigger],
.m3e-bottom-sheet-scrim[data-m3e-trigger],
.m3e-nav-drawer-scrim[data-m3e-trigger] {
  cursor: default;
}
/* Prevent click-through to content from triggering scrim close */
.m3e-dialog,
.m3e-bottom-sheet {
  pointer-events: auto;
}
/* Stop scrim close event from reaching the content */
.m3e-dialog,
.m3e-bottom-sheet { isolation: isolate; }

/* ═══════════════════════════════════════════════════════════════════════════
   Shell Layout — Phase 4
   ═══════════════════════════════════════════════════════════════════════════ */

.m3e-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.m3e-shell__body {
  display: flex;
  flex: 1;
}

/* Permanent drawer (committee/auditor desktop sidebar) */
.m3e-shell__drawer--permanent {
  position: fixed;
  top: 64px;
  left: 0;
  bottom: 0;
  width: 240px;
  z-index: 30;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  display: none;
}

/* Main content area */
.m3e-shell__content {
  flex: 1;
  padding-top: 64px;
  min-width: 0;
}

/* Bottom navigation bar (mobile) */
.m3e-shell__bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
}

/* Bottom padding to prevent content being hidden behind fixed bottom nav.
   Uses the same 840px breakpoint where the bottom nav hides. */
.m3e-shell__content--has-bottom-nav {
  padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
}


/* Desktop member tab bar (hidden on mobile) */
.m3e-shell__nav-tabs {
  display: none;
}

@media (min-width: 840px) {
  .m3e-shell__body {
    width: 100%;
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
  }
  .m3e-shell__drawer--permanent {
    display: block;
    position: sticky;
    top: 64px;
    left: auto;
    bottom: auto;
    height: calc(100vh - 64px);
    flex-shrink: 0;
  }
  /* Center top bar content to match shell body width */
  .m3e-top-app-bar--with-drawer > * {
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
  }
  .m3e-shell__bottom-nav {
    display: none;
  }
  .m3e-shell__content--has-bottom-nav {
    padding-bottom: 1.5rem;
  }
  .m3e-shell__nav-tabs {
    display: flex;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   KPI stat-card scroll strip (mobile → horizontal scroll, sm+ → grid)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 639px) {
  .m3e-kpi-strip {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .m3e-kpi-strip > * {
    flex: 0 0 65vw;
    scroll-snap-align: start;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   Global Scrollbar — M3E thin, tinted scrollbar
   ═══════════════════════════════════════════════════════════════════════════ */

/* Firefox / modern browsers */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--md-sys-color-outline-variant) transparent;
}

/* WebKit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--md-sys-color-outline);
}
/* Hide scrollbar on very small elements (tabs, horizontal strips) */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { scrollbar-width: none; }


/* ═══════════════════════════════════════════════════════════════════════════
 * EMPTY STATE
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--md-sys-spacing-16) var(--md-sys-spacing-4);
  text-align: center;
}
.m3e-empty-state__icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: color-mix(in srgb, var(--md-sys-color-primary-container) 55%, var(--md-sys-color-surface-container));
  color: var(--md-sys-color-on-primary-container);
  animation: m3e-float 3s ease-in-out infinite;
}
.m3e-empty-state__icon::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1.5px dashed var(--md-sys-color-outline-variant);
  opacity: 0.6;
}
.m3e-empty-state__icon svg {
  width: 36px;
  height: 36px;
}
.m3e-empty-state__icon--illustration svg {
  width: 100%;
  height: 100%;
}
.m3e-empty-state__heading {
  margin-top: var(--md-sys-spacing-5);
  font-size: var(--md-sys-typescale-title-large-size, 1.375rem);
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}
.m3e-empty-state__description {
  margin-top: var(--md-sys-spacing-2);
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  max-width: 320px;
}
@keyframes m3e-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .m3e-empty-state__icon { animation: none; }
}


/* ═══════════════════════════════════════════════════════════════════════════
 * FOCUS RING ANIMATION
 * ═══════════════════════════════════════════════════════════════════════════ */

@keyframes m3e-focus-ring {
  from { outline-offset: 6px; opacity: 0.5; }
  to   { outline-offset: 2px; opacity: 1; }
}
.m3e-button:focus-visible,
.m3e-chip:focus-visible,
.m3e-card--interactive:focus-visible,
.m3e-card[href]:focus-visible {
  animation: m3e-focus-ring 200ms var(--md-sys-motion-easing-expressive-spatial-fast);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * TOM SELECT OVERRIDES
 * Ensure TomSelect wrappers fill their parent container width.
 * ═══════════════════════════════════════════════════════════════════════════ */

.ts-wrapper {
  width: 100%;
  text-transform: none;
  letter-spacing: normal;
}

/* Make TomSelect single controls visually match native M3E selects.
   The outer wrapper already carries border/radius/padding classes from the form
   field, so the inner TomSelect control should be neutral. */
.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.single.has-items .ts-control,
.ts-wrapper.single.dropdown-active .ts-control {
  background: transparent;
  border: 0;
  box-shadow: none;
  min-height: 1.25em;
  padding: 0 !important;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}

.ts-wrapper.single .ts-control > .item {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  margin: 0 !important;
  padding: 0 !important;
  color: inherit;
  font: inherit;
  line-height: inherit;
  flex: 0 0 auto;
  white-space: nowrap;
}

.ts-wrapper.single .ts-control > input {
  margin: 0 !important;
  min-width: 0 !important;
  width: 0 !important;
  flex: 1 1 auto;
  padding: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
}

.ts-wrapper.single .ts-control input::placeholder {
  color: var(--md-sys-color-outline);
  opacity: 1;
}

/* When a value is selected, keep only a tiny caret-width input so it doesn't
   wrap onto a new line under the selected item. */
.ts-wrapper.single.has-items .ts-control > input {
  width: 2px !important;
  min-width: 2px !important;
  flex: 0 0 2px;
  margin-left: 2px !important;
}

/* Prevent label uppercase/tracking from leaking into form controls */
label.uppercase input,
label.uppercase select,
label.uppercase textarea,
label.uppercase .ts-wrapper {
  text-transform: none;
  letter-spacing: normal;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * SEGMENTED CONTROL
 * Outer container + inner pill items using M3E shape tokens.
 * ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
 * SEMANTIC STATUS UTILITIES
 * Map domain statuses to M3E color token families for theme-aware styling.
 *
 * Background + text pairs:
 *   .m3e-status-success   — tertiary-container  (green/purple family)
 *   .m3e-status-error     — error-container     (red family)
 *   .m3e-status-warning   — secondary-container (warm neutral family)
 *   .m3e-status-info      — primary-container   (blue family)
 *   .m3e-status-neutral   — surface-container   (neutral family)
 *
 * Text-only variants:
 *   .m3e-on-success, .m3e-on-error, .m3e-on-warning, .m3e-on-info
 *
 * Chip variants (bg + text + ring):
 *   .m3e-chip-confirmed, .m3e-chip-pending, .m3e-chip-available, .m3e-chip-cancelled
 * ═══════════════════════════════════════════════════════════════════════════ */

/* Status background + text pairs */
.m3e-status-success { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.m3e-status-error   { background: var(--md-sys-color-error-container);    color: var(--md-sys-color-on-error-container); }
.m3e-status-warning { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.m3e-status-info    { background: var(--md-sys-color-primary-container);  color: var(--md-sys-color-on-primary-container); }
.m3e-status-neutral { background: var(--md-sys-color-surface-container);  color: var(--md-sys-color-on-surface-variant); }

/* Text-only status colors */
.m3e-on-success { color: var(--md-sys-color-on-tertiary-container); }
.m3e-on-error   { color: var(--md-sys-color-error); }
.m3e-on-warning { color: var(--md-sys-color-on-secondary-container); }
.m3e-on-info    { color: var(--md-sys-color-on-primary-container); }

/* Chip variants: bg + text + CSS custom property for ring-color */
.m3e-chip-confirmed  { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); --chip-ring: var(--md-sys-color-tertiary); }
.m3e-chip-pending    { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); --chip-ring: var(--md-sys-color-secondary); }
.m3e-chip-available  { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); --chip-ring: var(--md-sys-color-primary); }
.m3e-chip-cancelled  { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); --chip-ring: var(--md-sys-color-error); }

/* Custom positive color — green is not in the MD3 core palette; used for "all booked" states */
:root,
.light {
  --md-custom-color-positive-container: rgb(200 230 201);
  --md-custom-color-on-positive-container: rgb(27 94 32);
}
.dark {
  --md-custom-color-positive-container: rgb(46 125 50);
  --md-custom-color-on-positive-container: rgb(200 230 201);
}


/* ═══════════════════════════════════════════════════════════════════════════
 * SEGMENTED CONTROL
 * Outer container + inner pill items using M3E shape tokens.
 * ═══════════════════════════════════════════════════════════════════════════ */

.m3e-seg-container {
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container);
}
.m3e-seg-pill {
  border-radius: var(--md-sys-shape-corner-small);
}
/* Animated sliding indicator for segmented controls */
.m3e-seg-indicator {
  position: absolute;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-sys-elevation-1);
  transition: transform 300ms var(--md-sys-motion-easing-spring),
              width 300ms var(--md-sys-motion-easing-spring);
  top: 2px; bottom: 2px; left: 0;
  pointer-events: none;
}


/* ═══════════════════════════════════════════════════════════════════════════
 * M3E VISUAL POLISH
 * Award-winning aesthetic layer — builds on top of existing M3E system.
 * All colors via --md-sys-color-* tokens; works in light + dark + HC modes.
 * ═══════════════════════════════════════════════════════════════════════════ */

/* Section header with left primary accent bar */
.m3e-section-header {
  display: flex;
  align-items: center;
  gap: var(--md-sys-spacing-3);
  padding: var(--md-sys-spacing-2) 0;
}
.m3e-section-header::before {
  content: '';
  display: block;
  width: 3px;
  height: 1.25em;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary);
  flex-shrink: 0;
}

/* KPI card top accent — set --kpi-accent on the element */
.m3e-card--accent-top {
  border-top: 3px solid var(--kpi-accent, var(--md-sys-color-primary));
}

/* Animated progress fill — spring-eases from 0 to full width on load */
.m3e-progress--fill-animate .m3e-progress__bar {
  animation: m3e-fill-in 600ms var(--md-sys-motion-easing-expressive-spatial-default, cubic-bezier(0.34, 1.56, 0.64, 1)) forwards;
  transform-origin: left;
}
@keyframes m3e-fill-in {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
  .m3e-progress--fill-animate .m3e-progress__bar { animation: none; }
}


/* ═══════════════════════════════════════════════════════════════════════════
 * Shell & Page Utilities (extracted from base.html)
 *
 * Companion keyframes live in motion.css.
 * ═══════════════════════════════════════════════════════════════════════════ */

/* ── Color-scheme: tell the browser whether we're light or dark so native
   controls (selects, checkboxes, scrollbars, date pickers) render correctly. ── */
:root { color-scheme: light; }
.dark { color-scheme: dark; }

/* ── Tokenised hover utility ── */
.hover-fill:hover { background: var(--md-sys-color-surface-container); }

/* ── User dropdown panel ── */
#user-dropdown-menu { background: var(--md-sys-color-surface-container); }
.dark #user-dropdown-menu { background: var(--md-sys-color-surface-container) !important; }

/* ── HTMX loading indicators ── */
/* ── Skeleton shimmer ── */
.m3e-skeleton {
  background: linear-gradient(
    90deg,
    var(--md-sys-color-surface-container) 25%,
    var(--md-sys-color-surface-container-high) 50%,
    var(--md-sys-color-surface-container) 75%
  );
  background-size: 200% 100%;
  animation: m3e-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--md-sys-shape-corner-small);
}
.m3e-skeleton--text { height: 14px; margin-bottom: 8px; }
.m3e-skeleton--title { height: 22px; width: 60%; margin-bottom: 12px; }
.m3e-skeleton--card { height: 72px; border-radius: var(--md-sys-shape-corner-medium); }
.m3e-skeleton--circle { border-radius: var(--md-sys-shape-corner-full); }
@keyframes m3e-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .m3e-skeleton { animation: none; }
}

.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request #page-loading-bar {
  animation: loading-slide 1.8s var(--md-sys-motion-easing-standard-spatial-default) infinite,
             loading-pulse-bar 0.8s ease-in-out infinite alternate;
}

/* ── Link utility classes ── */
.link-inline {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-underline-offset: 0.25rem;
}
.link-inline:hover { text-decoration-color: currentColor; }
.link-list-item:hover { text-decoration: underline; text-underline-offset: 0.125rem; }
.link-card { display: block; transition: box-shadow 0.2s, transform 0.2s; }
.link-card:hover { box-shadow: var(--md-sys-elevation-2); transform: scale(1.01); }

/* ── Global focus states ── */
a:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 2px; border-radius: 0.125rem; }
.bg-slate-900 a:focus-visible,
.bg-slate-950 a:focus-visible { outline-color: var(--md-sys-color-inverse-primary); }
.skip-link:focus-visible { outline: 3px solid var(--md-sys-color-primary); outline-offset: 2px; }

/* ── Card separator ── */
.card-separator { margin-left: 1rem; height: 0.5px; background: var(--md-sys-color-outline-variant); }

/* ── Nav active / inactive states ── */
.nav-active svg { color: var(--md-sys-color-on-secondary-container) !important; }
.nav-active .m3e-nav-bar__label { color: var(--md-sys-color-on-secondary-container) !important; font-weight: 600; }
.nav-active .nav-indicator { opacity: 1 !important; background: var(--md-sys-color-primary); }
.nav-inactive svg { color: var(--md-sys-color-on-surface-variant) !important; }
.nav-inactive .m3e-nav-bar__label { color: var(--md-sys-color-on-surface-variant) !important; }
.nav-inactive .nav-indicator { opacity: 0 !important; }
.member-top-nav-link { color: var(--md-sys-color-on-surface-variant); }
.member-top-nav-link:hover:not(.is-active) {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}
.member-top-nav-link:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.member-top-nav-link.is-active {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 600;
}

/* ── Sidebar nav ── */
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  border-radius: var(--md-sys-shape-corner-small);
  padding: 0.5rem 0.75rem;
  color: var(--md-sys-color-on-surface);
  transition: background 150ms;
}
.sidebar-link:hover { background: var(--md-sys-color-surface-container); }
.sidebar-section-label {
  padding: 0.5rem 0.75rem; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--md-sys-color-on-surface-variant);
}

/* ── Table interactive rows ── */
.table-row-interactive { transition: background 150ms; }

/* ── Navigation loading dim ── */
#page-content.nav-loading {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 120ms var(--md-sys-motion-easing-standard-effects-default);
}

/* ── In-page loading pulse ── */
.loading-pulse { animation: loading-pulse 1.5s ease-in-out infinite; }

/* ── Desktop hover states (hover-capable devices only) ── */
@media (hover: hover) {
  .table-row-interactive:hover { background: var(--md-sys-color-surface-container); }
  .table-row-danger { background: var(--md-sys-color-error-container); }
}

/* ── View Transitions ── */
@view-transition { navigation: auto; }
::view-transition-old(root) {
  animation: var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard-effects-default) vt-fade-out;
}
::view-transition-new(root) {
  animation: var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-expressive-spatial-default) vt-fade-in;
}

/* ── Sheet / modal animation classes ── */
.sheet-enter { animation: sheet-slide-up 350ms var(--md-sys-motion-easing-spring) forwards; }
.sheet-exit { animation: sheet-slide-down 250ms var(--md-sys-motion-easing-standard-effects-default) forwards; }
.modal-enter { animation: modal-scale-in 250ms var(--md-sys-motion-easing-spring) forwards; }
.modal-exit { animation: modal-scale-out 200ms var(--md-sys-motion-easing-standard-effects-default) forwards; }
.sheet-body-copy { text-align: left; line-height: 1.5; }
.sheet-body-copy p + p { margin-top: 0.5rem; }
.sheet-body-copy ul, .sheet-body-copy ol { margin-top: 0.5rem; padding-left: 1.1rem; }
.sheet-body-copy li + li { margin-top: 0.25rem; }

/* ── Mobile menu entrance / exit ── */
.menu-entering #mobile-menu-backdrop { animation: menu-backdrop-in 300ms var(--md-sys-motion-easing-standard-effects-default) forwards; }
.menu-entering #mobile-menu-panel { animation: menu-panel-in 300ms var(--md-sys-motion-easing-expressive-spatial-default); }
.menu-exiting #mobile-menu-backdrop { animation: menu-backdrop-out 250ms var(--md-sys-motion-easing-standard-effects-default) forwards; }
.menu-exiting #mobile-menu-panel { animation: menu-panel-out 300ms var(--md-sys-motion-easing-standard-effects-default) forwards; }

/* ── Nav item micro-interactions ── */
#mobile-nav-items > a {
  position: relative;
  transition: transform 120ms var(--md-sys-motion-easing-spring), background 150ms;
}
#mobile-nav-items > a:active { transform: scale(0.98); }
#mobile-nav-items > a[data-nav-active]::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-primary);
}

/* ── Tab bar transitions ── */
[data-nav-id] svg { transition: color 200ms, transform 300ms var(--md-sys-motion-easing-spring); }
[data-nav-id] span:last-child { transition: color 200ms, font-weight 200ms; }
.nav-active svg { transform: translateY(-1px); }
.nav-indicator { transition: opacity 250ms var(--md-sys-motion-easing-standard-effects-default); }
[data-nav-id]:active { transform: scale(0.92); transition: transform 100ms var(--md-sys-motion-easing-spring); }

/* ── Header scroll shadow ── */
header { transition: box-shadow 300ms var(--md-sys-motion-easing-standard-effects-default); }
header.scrolled { box-shadow: var(--md-sys-elevation-1); }

/* ── Segmented control sliding pill ── */
.seg-pill {
  position: absolute;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-sys-elevation-1);
  transition: transform 300ms var(--md-sys-motion-easing-spring),
              width 300ms var(--md-sys-motion-easing-spring);
  top: 2px; bottom: 2px; left: 0;
  pointer-events: none;
}

/* ── Number count-up ── */
.count-up { display: inline-block; }

/* ── Badge pulse on appear ── */
.badge-animate { animation: badge-pop 300ms var(--md-sys-motion-easing-spring) forwards; }

/* ── Section header slide ── */
.section-animate {
  opacity: 0;
  animation: section-slide 300ms var(--md-sys-motion-easing-standard-effects-default) forwards;
}

/* ── Accent left border (importance indicator) ── */
.card-accent-border { border-left: 3px solid var(--md-sys-color-primary); }

/* ── Form input focus animation ── */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):focus,
textarea:focus,
select:focus {
  box-shadow: 0 2px 0 0 var(--md-sys-color-primary);
  transition: box-shadow 200ms var(--md-sys-motion-easing-standard-effects-default);
}

/* ── Error message slide-in ── */
.field-error-animate {
  animation: error-slide-in 200ms var(--md-sys-motion-easing-standard-effects-default) forwards;
}

/* ── Read-only field visual distinction ── */
.field-readonly {
  cursor: not-allowed;
  transition: border-color 200ms var(--md-sys-motion-easing-standard-effects-default);
}
@media (hover: hover) {
  .field-readonly:hover { border-color: var(--md-sys-color-primary-container); }
}

/* ── Tom Select Dark Mode ── */
.dark .ts-wrapper .ts-control {
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline-variant);
}
.dark .ts-wrapper .ts-control input { color: var(--md-sys-color-on-surface); }
.dark .ts-dropdown {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline-variant);
}
.dark .ts-dropdown .option { color: var(--md-sys-color-on-surface); }
.dark .ts-dropdown .active {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}
.dark .ts-wrapper.focus .ts-control {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

/* ── Select / dropdown chevron indicator ──
   Native selects: appearance reset + SVG background chevron.
   TomSelect wrappers: ::after pseudo-element with theme-aware color. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2349454F' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem 1rem;
}
/* Dark mode: browsers default select bg to white — override with themed surface.
   Both .dark (class toggle) and [data-theme="dark"] (attribute) are set simultaneously
   by m3e-shell.js, so either selector works; both listed for safety. */
.dark select,
[data-theme="dark"] select {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23CAC4D0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.ts-wrapper.single {
  position: relative;
}
.ts-wrapper.single .ts-control {
  padding-right: 1.75rem !important;
}
.ts-wrapper.single::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  background-color: var(--md-sys-color-on-surface-variant);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  pointer-events: none;
  transition: transform 200ms var(--md-sys-motion-easing-standard-effects-default);
}
.ts-wrapper.single.dropdown-active::after {
  transform: translateY(-50%) rotate(180deg);
}

/* ── Safe area helpers ── */
.pb-safe { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* ── Court Grid Interactive Cells ─────────────────────────────────────── */
.m3e-court-grid-cell {
  cursor: pointer;
  transition: background-color var(--md-sys-motion-duration-short2)
              var(--md-sys-motion-easing-standard-effects-default);
}
.m3e-court-grid-cell:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}
.m3e-court-grid-cell[aria-expanded="true"] {
  background-color: var(--md-sys-color-secondary-container);
}
.m3e-court-grid-cell:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: -2px;
}
.m3e-court-grid-expand {
  border-top: 2px solid var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-low);
}

/* ── Details chevron ─────────────────────────────────────────────────────── */
details[open] > summary .details-chevron {
  transform: rotate(90deg);
}
