/* ==========================================================================
   MATERIAL YOU EXPRESSIVE (MATERIAL 3) DESIGN SYSTEM & TOKENS
   Following @material/web Guidelines (https://m3.material.io & MWC)
   ========================================================================== */

@import url('../assets/fonts/fonts.css');

:root {
  /* Typeface Tokens */
  --md-ref-typeface-brand: 'Roboto Flex', 'Google Sans', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  --md-ref-typeface-plain: 'Roboto Flex', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Material 3 Expressive Corner Shapes */
  --md-sys-shape-corner-none: 0px;
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 9999px;

  /* Material 3 Expressive Elevations */
  --md-sys-elevation-level-0: none;
  --md-sys-elevation-level-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(0, 0, 0, 0.12);
  --md-sys-elevation-level-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(0, 0, 0, 0.14);
  --md-sys-elevation-level-3: 0px 4px 12px 3px rgba(0, 0, 0, 0.08), 0px 1px 3px 0px rgba(0, 0, 0, 0.14);
  --md-sys-elevation-level-4: 0px 6px 16px 4px rgba(0, 0, 0, 0.09), 0px 2px 4px 0px rgba(0, 0, 0, 0.14);
  --md-sys-elevation-level-5: 0px 8px 24px 6px rgba(0, 0, 0, 0.10), 0px 4px 8px 0px rgba(0, 0, 0, 0.14);

  /* ==========================================================================
     MATERIAL DESIGN 3 MOTION SYSTEM (https://m3.material.io/styles/motion/overview/how-it-works)
     ========================================================================== */
  /* M3 Easing Tokens */
  --md-sys-motion-easing-linear: cubic-bezier(0, 0, 1, 1);
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0.0, 0, 1.0);
  --md-sys-motion-easing-standard-decelerate: cubic-bezier(0.0, 0.0, 0.2, 1.0);
  --md-sys-motion-easing-standard-accelerate: cubic-bezier(0.3, 0.0, 1.0, 1.0);
  --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0.0, 0, 1.0);
  --md-sys-motion-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1.0);
  --md-sys-motion-easing-emphasized-accelerate: cubic-bezier(0.3, 0.0, 0.8, 0.15);
  --md-sys-motion-easing-expressive: cubic-bezier(0.05, 0.7, 0.1, 1.0);
  --md-sys-motion-easing-spring: cubic-bezier(0.34, 1.35, 0.64, 1.0);

  /* M3 Duration Tokens */
  --md-sys-motion-duration-short1: 50ms;
  --md-sys-motion-duration-short2: 100ms;
  --md-sys-motion-duration-short3: 150ms;
  --md-sys-motion-duration-short4: 200ms;
  --md-sys-motion-duration-medium1: 250ms;
  --md-sys-motion-duration-medium2: 300ms;
  --md-sys-motion-duration-medium3: 350ms;
  --md-sys-motion-duration-medium4: 400ms;
  --md-sys-motion-duration-long1: 450ms;
  --md-sys-motion-duration-long2: 500ms;
  --md-sys-motion-duration-long3: 550ms;
  --md-sys-motion-duration-long4: 600ms;
  --md-sys-motion-duration-extra-long1: 700ms;
  --md-sys-motion-duration-extra-long2: 800ms;
  --md-sys-motion-duration-extra-long3: 900ms;
  --md-sys-motion-duration-extra-long4: 1000ms;

  /* Backward Compatibility Aliases */
  --md-sys-motion-duration-short: var(--md-sys-motion-duration-short3);
  --md-sys-motion-duration-medium: var(--md-sys-motion-duration-medium2);
  --md-sys-motion-duration-long: var(--md-sys-motion-duration-long2);

  /* Light Theme Color Roles (Material You Vibrant Expressive Palette) */
  --md-sys-color-primary: #1a56db;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #dbeafe;
  --md-sys-color-on-primary-container: #1e3a8a;

  --md-sys-color-secondary: #4f46e5;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #ede9fe;
  --md-sys-color-on-secondary-container: #3730a3;

  --md-sys-color-tertiary: #7c3aed;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #f3e8ff;
  --md-sys-color-on-tertiary-container: #581c87;

  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;

  --md-sys-color-success: #15803d;
  --md-sys-color-on-success: #ffffff;
  --md-sys-color-success-container: #dcfce7;
  --md-sys-color-on-success-container: #14532d;

  --md-sys-color-warning: #b45309;
  --md-sys-color-on-warning: #ffffff;
  --md-sys-color-warning-container: #fef3c7;
  --md-sys-color-on-warning-container: #78350f;

  --md-sys-color-background: #f8fafc;
  --md-sys-color-on-background: #0f172a;

  --md-sys-color-surface: #f8fafc;
  --md-sys-color-on-surface: #0f172a;
  --md-sys-color-on-surface-variant: #475569;

  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f1f5f9;
  --md-sys-color-surface-container: #e2e8f0;
  --md-sys-color-surface-container-high: #cbd5e1;
  --md-sys-color-surface-container-highest: #94a3b8;

  --md-sys-color-outline: #64748b;
  --md-sys-color-outline-variant: #e2e8f0;

  /* Material Web Components Overrides */
  --md-filled-button-container-shape: var(--md-sys-shape-corner-full);
  --md-outlined-button-container-shape: var(--md-sys-shape-corner-full);
  --md-elevated-button-container-shape: var(--md-sys-shape-corner-full);
  --md-filled-tonal-button-container-shape: var(--md-sys-shape-corner-full);
  --md-dialog-container-shape: var(--md-sys-shape-corner-extra-large);
  --md-dialog-container-color: var(--md-sys-color-surface-container-lowest);
  --md-fab-container-shape: 18px;

  /* Material 3 Switch Component Overrides */
  --md-switch-track-width: 52px;
  --md-switch-track-height: 32px;
  --md-switch-selected-track-color: var(--md-sys-color-primary);
  --md-switch-selected-handle-color: var(--md-sys-color-on-primary);
  --md-switch-selected-hover-track-color: var(--md-sys-color-primary);
  --md-switch-selected-focus-track-color: var(--md-sys-color-primary);
  --md-switch-selected-pressed-track-color: var(--md-sys-color-primary);

  /* Material 3 Four-Color Progress Indicator Tokens */
  --md-circular-progress-four-color-active-indicator-one-color: #3b82f7;
  --md-circular-progress-four-color-active-indicator-two-color: #ea4335;
  --md-circular-progress-four-color-active-indicator-three-color: #fbbc04;
  --md-circular-progress-four-color-active-indicator-four-color: #34a853;

  --md-linear-progress-four-color-active-indicator-one-color: #3b82f7;
  --md-linear-progress-four-color-active-indicator-two-color: #ea4335;
  --md-linear-progress-four-color-active-indicator-three-color: #fbbc04;
  --md-linear-progress-four-color-active-indicator-four-color: #34a853;
  --md-linear-progress-track-color: rgba(226, 232, 240, 0.6);
  --md-linear-progress-track-shape: var(--md-sys-shape-corner-full);
  --md-linear-progress-track-height: 4px;
  --md-linear-progress-active-indicator-height: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --md-sys-color-primary: #93c5fd;
    --md-sys-color-on-primary: #1e3a8a;
    --md-sys-color-primary-container: #1e40af;
    --md-sys-color-on-primary-container: #dbeafe;

    --md-sys-color-secondary: #c4b5fd;
    --md-sys-color-on-secondary: #3730a3;
    --md-sys-color-secondary-container: #4338ca;
    --md-sys-color-on-secondary-container: #ede9fe;

    --md-sys-color-tertiary: #d8b4fe;
    --md-sys-color-on-tertiary: #581c87;
    --md-sys-color-tertiary-container: #6b21a8;
    --md-sys-color-on-tertiary-container: #f3e8ff;

    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error-container: #ffdad6;

    --md-sys-color-success: #86efac;
    --md-sys-color-on-success: #14532d;
    --md-sys-color-success-container: #166534;
    --md-sys-color-on-success-container: #dcfce7;

    --md-sys-color-warning: #fde047;
    --md-sys-color-on-warning: #713f12;
    --md-sys-color-warning-container: #854d0e;
    --md-sys-color-on-warning-container: #fef9c3;

    --md-sys-color-background: #0f172a;
    --md-sys-color-on-background: #f8fafc;

    --md-sys-color-surface: #0f172a;
    --md-sys-color-on-surface: #f8fafc;
    --md-sys-color-on-surface-variant: #94a3b8;

    --md-sys-color-surface-container-lowest: #020617;
    --md-sys-color-surface-container-low: #1e293b;
    --md-sys-color-surface-container: #334155;
    --md-sys-color-surface-container-high: #475569;
    --md-sys-color-surface-container-highest: #64748b;

    --md-sys-color-outline: #94a3b8;
    --md-sys-color-outline-variant: #334155;

    /* Dark Mode Four-Color Indicator Tokens */
    --md-circular-progress-four-color-active-indicator-one-color: #8ab4f8;
    --md-circular-progress-four-color-active-indicator-two-color: #f28b82;
    --md-circular-progress-four-color-active-indicator-three-color: #fdd663;
    --md-circular-progress-four-color-active-indicator-four-color: #81c995;

    --md-linear-progress-four-color-active-indicator-one-color: #8ab4f8;
    --md-linear-progress-four-color-active-indicator-two-color: #f28b82;
    --md-linear-progress-four-color-active-indicator-three-color: #fdd663;
    --md-linear-progress-four-color-active-indicator-four-color: #81c995;
    --md-linear-progress-track-color: rgba(51, 65, 85, 0.6);
  }
}

/* Brand Expressive Page Titles (Material You Roboto Flex Variable) */
.brand-page-title {
  font-family: 'Roboto Flex', sans-serif !important;
  font-variation-settings: 'opsz' 144, 'wdth' 135, 'wght' 1000, 'XOPQ' 154, 'XTRA' 518, 'YOPQ' 53, 'YTDE' -203, 'YTFI' 738, 'YTLC' 514, 'YTUC' 712 !important;
  font-weight: 1000 !important;
  color: #3b82f7 !important;
}

/* ==========================================================================
   MATERIAL 3 RIPPLE SYSTEM
   ========================================================================== */

button,
.m3-btn-expressive,
.tab-btn,
.action-btn,
[role="button"],
.ripple-surface {
  position: relative;
}

.m3-ripple-host {
  position: absolute !important;
  inset: 0 !important;
  overflow: hidden !important;
  border-radius: inherit !important;
  pointer-events: none !important;
  contain: strict !important;
  z-index: 10 !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  box-sizing: border-box !important;
}

.m3-ripple-wave {
  position: absolute !important;
  border-radius: 50% !important;
  pointer-events: none !important;
  background-color: currentColor;
  opacity: 0.16;
  transform: scale(0);
  animation: m3-ripple-expand 350ms cubic-bezier(0.2, 0, 0, 1) forwards;
  will-change: transform, opacity;
}

.m3-ripple-wave.fade-out {
  opacity: 0 !important;
  transition: opacity 250ms cubic-bezier(0.2, 0, 0, 1) !important;
}

@keyframes m3-ripple-expand {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

/* Ensure tab icons turn pure white when tab is selected */
#tab-ai-chat-btn.bg-purple-600 img,
#tab-ai-chat-btn.text-white img,
#tab-ai-chat-btn[aria-selected="true"] img,
.tab-selected img {
  filter: none !important;
}

/* Material 3 Switch Component */
md-switch {
  display: inline-flex;
  vertical-align: middle;
  flex-shrink: 0;
  cursor: pointer;
  --md-focus-ring-shape: var(--md-sys-shape-corner-full);
}

/* Material 3 Outlined Text Field Component */
md-outlined-text-field {
  display: block;
  width: 100%;
  font-family: inherit;
  --md-outlined-text-field-container-shape: 16px;
  --md-outlined-text-field-outline-color: var(--md-sys-color-outline-variant, #cbd5e1);
  --md-outlined-text-field-hover-outline-color: var(--md-sys-color-outline, #94a3b8);
  --md-outlined-text-field-focus-outline-color: var(--md-sys-color-primary, #1a56db);
  --md-outlined-text-field-label-text-color: var(--md-sys-color-on-surface-variant, #64748b);
  --md-outlined-text-field-hover-label-text-color: var(--md-sys-color-on-surface-variant, #475569);
  --md-outlined-text-field-focus-label-text-color: var(--md-sys-color-primary, #1a56db);
  --md-outlined-text-field-input-text-color: var(--md-sys-color-on-surface, #0f172a);
  --md-outlined-text-field-supporting-text-color: var(--md-sys-color-on-surface-variant, #64748b);
}

@media (prefers-color-scheme: dark) {
  md-outlined-text-field {
    --md-outlined-text-field-outline-color: var(--md-sys-color-outline-variant, #334155);
    --md-outlined-text-field-hover-outline-color: var(--md-sys-color-outline, #64748b);
    --md-outlined-text-field-focus-outline-color: var(--md-sys-color-primary, #93c5fd);
    --md-outlined-text-field-label-text-color: var(--md-sys-color-on-surface-variant, #94a3b8);
    --md-outlined-text-field-hover-label-text-color: var(--md-sys-color-on-surface-variant, #cbd5e1);
    --md-outlined-text-field-focus-label-text-color: var(--md-sys-color-primary, #93c5fd);
    --md-outlined-text-field-input-text-color: var(--md-sys-color-on-surface, #f8fafc);
    --md-outlined-text-field-supporting-text-color: var(--md-sys-color-on-surface-variant, #94a3b8);
  }
}

/* ==========================================================================
   MATERIAL DESIGN 3 MOTION PATTERNS (https://m3.material.io/styles/motion)
   ========================================================================== */

/* 1. M3 Shared Axis X: Horizontal Peer & Tab Transitions */
@keyframes m3-shared-axis-x-forward-in {
  from {
    opacity: 0;
    transform: translateX(36px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes m3-shared-axis-x-forward-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-36px);
  }
}

@keyframes m3-shared-axis-x-backward-in {
  from {
    opacity: 0;
    transform: translateX(-36px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes m3-shared-axis-x-backward-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(36px);
  }
}

.m3-tab-panel-enter-forward {
  animation: m3-shared-axis-x-forward-in var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate) both;
}

.m3-tab-panel-enter-backward {
  animation: m3-shared-axis-x-backward-in var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate) both;
}

/* 2. M3 Fade Through (Dashboard <-> Editor & High-Level Transitions) */
@keyframes m3-fade-through-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes m3-fade-through-out {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

.m3-fade-through-enter {
  animation: m3-fade-through-in var(--md-sys-motion-duration-medium3) var(--md-sys-motion-easing-emphasized-decelerate) both;
}

.m3-fade-through-exit {
  animation: m3-fade-through-out var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized-accelerate) both;
}

/* 3. M3 Shared Axis Z / Dialog Scale-Elevation Entrance */
@keyframes m3-dialog-enter {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.m3-dialog-enter {
  animation: m3-dialog-enter var(--md-sys-motion-duration-medium3) var(--md-sys-motion-easing-emphasized-decelerate) both;
}

.modal-overlay:not(.hidden) {
  animation: m3-backdrop-fade-in var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard) both;
}

/* 4. M3 View Transitions API Integration (Modern Web Guidance) */
::view-transition-old(m3-tab-content),
::view-transition-new(m3-tab-content) {
  animation-duration: var(--md-sys-motion-duration-medium2);
}

html:active-view-transition-type(forward)::view-transition-old(m3-tab-content) {
  animation: m3-shared-axis-x-forward-out var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized-accelerate) both;
}

html:active-view-transition-type(forward)::view-transition-new(m3-tab-content) {
  animation: m3-shared-axis-x-forward-in var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate) both;
}

html:active-view-transition-type(backward)::view-transition-old(m3-tab-content) {
  animation: m3-shared-axis-x-backward-out var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized-accelerate) both;
}

html:active-view-transition-type(backward)::view-transition-new(m3-tab-content) {
  animation: m3-shared-axis-x-backward-in var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate) both;
}

html:active-view-transition-type(fade-through)::view-transition-old(m3-view-content) {
  animation: m3-fade-through-out var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized-accelerate) both;
}

html:active-view-transition-type(fade-through)::view-transition-new(m3-view-content) {
  animation: m3-fade-through-in var(--md-sys-motion-duration-medium3) var(--md-sys-motion-easing-emphasized-decelerate) both;
}

/* Material Symbols Helper */
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'liga';
}

/* Global Styles & Animations */
body {
    font-family: var(--md-ref-typeface-plain);
    overflow-x: hidden;
    overflow-y: auto;
    color: var(--md-sys-color-on-background);
}

/* Material 3 Expressive Component Utilities */
.m3-card-expressive {
    background-color: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-sys-elevation-level-2);
    transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-expressive),
                box-shadow var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-expressive),
                border-color var(--md-sys-motion-duration-short) ease;
}

.m3-card-expressive:hover {
    box-shadow: var(--md-sys-elevation-level-3);
}

.m3-btn-expressive {
    font-family: var(--md-ref-typeface-plain);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.015em;
    border-radius: var(--md-sys-shape-corner-full);
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    transition: transform 0.2s var(--md-sys-motion-easing-expressive),
                box-shadow 0.2s var(--md-sys-motion-easing-expressive),
                filter 0.2s ease, background 0.2s ease;
    cursor: pointer;
    border: none;
    outline: none;
}

.m3-btn-expressive:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.015);
    filter: brightness(1.05);
}

.m3-btn-expressive:active:not(:disabled) {
    transform: translateY(1px) scale(0.985);
    filter: brightness(0.95);
}

.m3-btn-filled {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--md-sys-elevation-level-1);
}

.m3-btn-filled:hover:not(:disabled) {
    box-shadow: var(--md-sys-elevation-level-2);
}

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

.m3-btn-tertiary-tonal {
    background: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
}

.m3-btn-outlined {
    background: transparent;
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
}

.m3-btn-outlined:hover:not(:disabled) {
    background: var(--md-sys-color-primary-container);
    border-color: var(--md-sys-color-primary);
}

.m3-btn-text {
    background: transparent;
    color: var(--md-sys-color-primary);
    box-shadow: none;
    padding: 0.5rem 1rem;
}

.m3-btn-text:hover:not(:disabled) {
    background: rgba(26, 86, 219, 0.08);
    box-shadow: none;
    transform: none;
}

/* Material 3 Expressive Chips */
.m3-chip-expressive {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.35rem 0.85rem;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    transition: all 0.2s var(--md-sys-motion-easing-expressive);
}

.m3-chip-expressive:hover {
    background: var(--md-sys-color-surface-container);
    border-color: var(--md-sys-color-outline);
}

.m3-chip-selected {
    background: var(--md-sys-color-primary-container) !important;
    color: var(--md-sys-color-on-primary-container) !important;
    border-color: var(--md-sys-color-primary) !important;
}

/* Material 3 Expressive Dialog */
.m3-dialog-card {
    background: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-sys-elevation-level-4);
    border: 1px solid var(--md-sys-color-outline-variant);
    overflow: hidden;
}

/* Material 3 Expressive Progress Bar */
.m3-linear-progress {
    height: 6px;
    border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-surface-container);
    overflow: hidden;
    position: relative;
}

.m3-linear-progress-bar {
    height: 100%;
    border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-primary);
    transition: width 0.35s var(--md-sys-motion-easing-expressive);
}

.glow-correct {
    box-shadow: 0 0 20px 7px rgba(74, 222, 128, 0.6);
}

.glow-incorrect {
    box-shadow: 0 0 20px 7px rgba(239, 68, 68, 0.6);
}

#question-card {
    transition: box-shadow 0.4s ease-in-out;
}

/* Card Shake on Wrong Guess */
@keyframes cardShake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    15% {
        transform: translateX(-10px) rotate(-1.5deg);
    }
    30% {
        transform: translateX(9px) rotate(1.2deg);
    }
    45% {
        transform: translateX(-7px) rotate(-0.8deg);
    }
    60% {
        transform: translateX(5px) rotate(0.5deg);
    }
    75% {
        transform: translateX(-3px) rotate(-0.2deg);
    }
    90% {
        transform: translateX(1px) rotate(0deg);
    }
}

.card-shake {
    animation: cardShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Card Place-Behind-Deck Animation */
@keyframes cardToBack {
    0% {
        transform: translateY(0) scale(1) rotate(0deg);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        z-index: 25;
        opacity: 1;
        filter: brightness(1);
    }
    35% {
        transform: translateY(-45px) scale(1.03) rotate(-1.5deg);
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
        z-index: 25;
        opacity: 1;
        filter: brightness(1.02);
    }
    40% {
        z-index: 5;
    }
    65% {
        transform: translateY(-5px) scale(0.94) rotate(0.5deg);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        z-index: 5;
        opacity: 0.85;
        filter: brightness(0.9);
    }
    100% {
        transform: translateY(35px) scale(0.9) rotate(1deg);
        box-shadow: none;
        z-index: 5;
        opacity: 0;
        filter: brightness(0.75);
    }
}

.anim-card-to-back {
    animation: cardToBack 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Score Pulse Effect */
@keyframes scorePulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.35);
        filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.8));
    }
    100% {
        transform: scale(1);
    }
}

.score-pulse {
    animation: scorePulse 0.35s ease-out;
}

.hidden {
    display: none;
}

#delete-card-btn {
    transition: opacity 0.2s ease-in-out, transform 0.1s;
}

#delete-card-btn:active {
    transform: scale(0.9);
}

.modal-overlay {
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Modal Inner Card Physical Entrance Animation (M3 Shared Axis Z / Elevate) */
.modal-overlay:not(.hidden) > div,
.modal-overlay:not(.hidden) > form > div,
#transfer-modal:not(.hidden) #transfer-modal-content {
    animation: modalEnter var(--md-sys-motion-duration-medium3) var(--md-sys-motion-easing-emphasized-decelerate) forwards;
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Custom Scrollbars */
textarea::-webkit-scrollbar,
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}

textarea::-webkit-scrollbar-track,
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

textarea::-webkit-scrollbar-thumb,
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
}

/* Animations */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 3px solid #3b82f6;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.5rem 0.75rem;
    background: #f3f4f6;
    border-radius: 0.75rem 0.75rem 0.75rem 0;
    width: fit-content;
    align-self: flex-start;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* AI Chat Layout & Message Styles */
#ai-chat-container {
    right: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 767px) {
    #ai-chat-container {
        transform: translateY(100%);
        height: 75vh;
        height: 75dvh;
        max-height: calc(100dvh - 3rem);
        border-radius: 1.5rem 1.5rem 0 0;
        box-shadow: 0 -10px 30px -5px rgba(0, 0, 0, 0.25);
    }

    #ai-chat-container.open {
        transform: translateY(0);
    }
}

@media (min-width: 768px) {
    #ai-chat-container {
        transform: translateX(100%);
        height: 70vh;
        max-height: 680px;
        top: 15vh;
        border-radius: 1.25rem 0 0 1.25rem;
        box-shadow: -10px 0 30px -5px rgba(0, 0, 0, 0.25);
    }

    #ai-chat-container.open {
        transform: translateX(0);
    }
}

.chat-message-ai {
    background: #f3f4f6;
    color: #1f2937;
    padding: 0.75rem;
    border-radius: 0.75rem 0.75rem 0.75rem 0;
    max-width: 85%;
    align-self: flex-start;
    font-size: 0.875rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-message-user {
    background: #7c3aed;
    color: white;
    padding: 0.75rem;
    border-radius: 0.75rem 0.75rem 0 0.75rem;
    max-width: 85%;
    align-self: flex-end;
    font-size: 0.875rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Markdown Rendering in AI Chat */
.chat-message-ai p {
    margin-bottom: 0.5rem;
}

.chat-message-ai p:last-child {
    margin-bottom: 0;
}

.chat-message-ai ul,
.chat-message-ai ol {
    margin-left: 1.25rem;
    margin-bottom: 0.5rem;
}

.chat-message-ai ul {
    list-style-type: disc;
}

.chat-message-ai ol {
    list-style-type: decimal;
}

.chat-message-ai code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    font-family: monospace;
}

.chat-message-ai pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.chat-message-ai strong {
    font-weight: 700;
}

/* Dashboard Specific Styles */
.squircle {
    width: 64px;
    height: 64px;
    background-color: #93c5fd;
    color: #1e40af;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    border-radius: 18px;
    text-transform: uppercase;
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.2);
    border: 2px solid white;
    transition: transform 0.2s ease;
}

.squircle:hover {
    transform: scale(1.05);
}

/* Minimalistic Light & Shadow Ambient Gradients */
@keyframes ambientLightShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.generating-deck-bg {
    background: linear-gradient(135deg, #f8fafc 0%, #ede9fe 50%, #f1f5f9 100%) !important;
    background-size: 200% 200% !important;
    animation: ambientLightShift 12s ease-in-out infinite !important;
}

/* Mobile Header Overlap & Focus Handling */
#game-container, #question-card, #answer-input, #answer-input-1, #answer-input-2 {
    scroll-margin-top: 60px;
}

@media (max-width: 767px) {
    #game-container {
        margin-top: 56px;
        margin-bottom: 16px;
    }

    /* When keyboard is active on mobile, compact elements to keep card in focus */
    body.keyboard-open #game-container,
    @media (max-height: 580px) {
        #game-container {
            margin-top: 52px;
            margin-bottom: 8px;
            padding: 0.85rem;
        }

        #question-card {
            padding: 0.75rem;
            margin-bottom: 0.5rem;
            min-height: 70px;
        }

        #question-image {
            max-height: 7.5rem;
        }

        #question-text {
            font-size: 0.925rem;
            line-height: 1.35;
        }

        #open-answer-area, #open-double-answer-area, #action-buttons-area {
            margin-top: 0.5rem;
        }
    }
}

/* AI Chat Separator */
.chat-separator {
    width: 100%;
    margin: 1.5rem 0 1rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.chat-separator img {
    width: 60%;
    max-width: 150px;
    opacity: 0.4;
}

.chat-question-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
}

/* Flashcard Image Styling & Lightbox Zoom */
.card-img-zoomable {
    cursor: zoom-in;
    transition: transform 0.2s ease-in-out, filter 0.2s ease-in-out;
}

.card-img-zoomable:hover {
    transform: scale(1.015);
    filter: brightness(1.03);
}

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   MINIMALISTIC SKEUOMORPHIC ANIMATIONS & LIGHT/SHADOW EFFECTS
   ========================================================================== */

/* Subtle Specular Light Sheen */
@keyframes subtleShimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(200%);
    }
}

.animate-shimmer {
    animation: subtleShimmer 3.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* Skeuomorphic Progress Bar Light Glide (monochromatic directional flow) */
@keyframes skeuomorphicGlide {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(35%);
    }
    100% {
        transform: translateX(180%);
    }
}

.animate-pulse-progress {
    width: 45%;
    animation: skeuomorphicGlide 2.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* ==========================================================================
   M3 DYNAMIC BORDER RADIUS FOR EDITOR DECK CARDS (CONNECTED GROUP)
   Reference: Material 3 Grouped List / Card Deck (Temp/card deck.png)
   ========================================================================== */
.flashcard-item {
    border-radius: var(--md-sys-shape-corner-extra-small, 4px);
    transition: border-radius var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized),
                box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
                border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

/* Single card in deck/group: fully rounded outer edges */
.flashcard-item.m3-card-shape-single,
#cards-list > .flashcard-item:only-child {
    border-radius: 24px !important;
}

/* First card in deck/group: rounded top, subtle bottom */
.flashcard-item.m3-card-shape-first,
#cards-list > .flashcard-item:first-child:not(:last-child) {
    border-radius: 24px 24px 4px 4px !important;
}

/* Middle cards in deck/group: subtle rounded edges throughout */
.flashcard-item.m3-card-shape-mid {
    border-radius: 4px !important;
}

/* Last card in deck/group: subtle top, rounded bottom */
.flashcard-item.m3-card-shape-last,
#cards-list > .flashcard-item:last-child:not(:first-child) {
    border-radius: 4px 4px 24px 24px !important;
}

/* ==========================================================================
   M3 ELASTIC COLLISION ENTRANCE ANIMATION FOR NEW DECK CARDS
   ========================================================================== */

/* Physical Card Enter (standard static fallback / damped inertia) */
@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.995);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-enter-anim {
    animation: cardEnter var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-emphasized-decelerate) forwards;
}

/* 1. New card enters from below, strikes the previous card, and dampens into place */
@keyframes m3CardElasticIn {
    0% {
        opacity: 0;
        transform: translateY(76px) scale(0.96);
    }
    20% {
        opacity: 0.95;
    }
    38% {
        opacity: 1;
        /* Kinetic impact overshoot against the card above */
        transform: translateY(-12px) scale(1.015, 0.985);
    }
    64% {
        /* Rebounds downward due to reaction force */
        transform: translateY(5px) scale(0.995, 1.005);
    }
    82% {
        /* Damped oscillation settling upward */
        transform: translateY(-2px) scale(1.002, 0.998);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 2. Previous card absorbs impact from below, bounces upward, and dampens back into place */
@keyframes m3CardElasticCollisionHit {
    0% {
        transform: translateY(0) scale(1);
    }
    22% {
        /* At rest waiting for incoming card impact */
        transform: translateY(0) scale(1);
    }
    42% {
        /* Impact shock! Propelled upward by kinetic impulse with slight vertical stretch */
        transform: translateY(-20px) scale(0.985, 1.025);
        box-shadow: 0 12px 24px -4px rgba(59, 130, 246, 0.22), 0 4px 8px -2px rgba(0, 0, 0, 0.08);
    }
    68% {
        /* Damped spring rebound downward past equilibrium */
        transform: translateY(7px) scale(1.015, 0.985);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    }
    84% {
        /* Secondary gentle upward oscillation */
        transform: translateY(-2.5px) scale(1);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
    }
    100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }
}

.m3-card-elastic-in {
    animation: m3CardElasticIn 540ms cubic-bezier(0.22, 1, 0.36, 1) both;
    will-change: transform, opacity;
    z-index: 10;
}

.m3-card-elastic-collision-hit {
    animation: m3CardElasticCollisionHit 580ms cubic-bezier(0.22, 1, 0.36, 1) both;
    will-change: transform, box-shadow;
    z-index: 11;
}

/* ==========================================================================
   M3 OUTLINED SELECT & ANIMATED DROPDOWN MENU
   Reference: Material 3 Outlined Select (Temp/Menu.png & open dropdown animation.mp4)
   ========================================================================== */
#creator-card-type-wrapper {
    width: 100%;
}

#creator-card-type-box {
    position: relative;
    width: 100%;
}

/* Floating Notched Label */
.m3-select-label {
    position: absolute;
    top: -9px;
    left: 12px;
    padding: 0 6px;
    background-color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #4f46e5;
    z-index: 10;
    pointer-events: none;
    border-radius: 4px;
    transition: color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

/* Outlined Trigger Button */
.m3-select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    outline: none;
    cursor: pointer;
    user-select: none;
    transition: border-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
                box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.m3-select-trigger:hover {
    border-color: #6366f1;
}

.m3-select-trigger.active,
.m3-select-trigger:focus-visible {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Trailing Chevron Animation */
.m3-select-chevron {
    transition: transform 240ms cubic-bezier(0.2, 0, 0, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    flex-shrink: 0;
}

.m3-select-trigger.active .m3-select-chevron {
    transform: rotate(180deg);
    color: #4f46e5;
}

/* Dropdown Menu Container (Elevated M3 Surface, anchored flush to button, overlays hint text) */
.m3-select-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background-color: #ffffff;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(203, 213, 225, 0.95);
    border-radius: 16px;
    padding: 0.375rem;
    box-shadow: 0 14px 36px -4px rgba(15, 23, 42, 0.16), 0 6px 16px -2px rgba(15, 23, 42, 0.08);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transform-origin: top center;
}

/* Opening & Closing Animations (Ref: Temp/open dropdown animation.mp4) */
@keyframes m3DropdownOpen {
    0% {
        opacity: 0;
        transform: scaleY(0.88) translateY(-6px);
    }
    100% {
        opacity: 1;
        transform: scaleY(1) translateY(0);
    }
}

@keyframes m3DropdownClose {
    0% {
        opacity: 1;
        transform: scaleY(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scaleY(0.92) translateY(-4px);
    }
}

.m3-dropdown-open {
    animation: m3DropdownOpen 220ms cubic-bezier(0.05, 0.7, 0.1, 1.0) forwards;
}

.m3-dropdown-close {
    animation: m3DropdownClose 150ms cubic-bezier(0.3, 0.0, 0.8, 0.15) forwards;
}

/* Menu Item & Selected Pill State (Ref: Temp/Menu.png) */
.m3-select-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    color: #1e293b;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard),
                color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}

.m3-select-item:hover:not(.m3-select-item-selected) {
    background-color: #f1f5f9;
    color: #1a56db;
}

/* Selected Item: Soft Expressive Violet/Lavender Container Pill */
.m3-select-item.m3-select-item-selected {
    background-color: #f3e8ff; /* Soft M3 Tertiary Container / lavender from Menu.png */
    color: #581c87;            /* Deep on-tertiary-container purple */
    font-weight: 700;
}

.m3-select-item .m3-select-check {
    display: none;
    color: #7c3aed;
    flex-shrink: 0;
}

.m3-select-item.m3-select-item-selected .m3-select-check {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dark Mode support for M3 Select */
.dark .m3-select-label {
    background-color: #1e293b;
    color: #818cf8;
}
.dark .m3-select-trigger {
    background-color: #1e293b;
    border-color: #475569;
    color: #f8fafc;
}
.dark .m3-select-dropdown {
    background-color: #1e293b;
    border-color: #475569;
    box-shadow: 0 14px 36px -4px rgba(0, 0, 0, 0.5), 0 6px 16px -2px rgba(0, 0, 0, 0.3);
}
.dark .m3-select-item {
    color: #f1f5f9;
}
.dark .m3-select-item:hover:not(.m3-select-item-selected) {
    background-color: #334155;
    color: #93c5fd;
}
.dark .m3-select-item.m3-select-item-selected {
    background-color: #3b2d54;
    color: #e9d5ff;
}
.dark .m3-select-item.m3-select-item-selected .m3-select-check {
    color: #c084fc;
}

/* Subtle Breathing Glow (tactile light reflection) */
@keyframes badgeBreathing {
    0%, 100% {
        box-shadow: 0 1px 3px rgba(124, 58, 237, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.25);
        opacity: 1;
    }
    50% {
        box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45);
        opacity: 0.92;
    }
}

.badge-generating-pulse {
    animation: badgeBreathing 2.4s ease-in-out infinite;
}

.spinner.w-3 {
    width: 0.75rem;
    height: 0.75rem;
    border-width: 2px;
}

/* Minimalist Ambient Backlight */
@keyframes geminiAmbientLight {
    0%, 100% {
        box-shadow: 0 4px 14px -2px rgba(124, 58, 237, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: 0 6px 20px -2px rgba(124, 58, 237, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }
}

.animate-gemini-glow {
    animation: geminiAmbientLight 3s ease-in-out infinite;
}

/* Skeuomorphic Depth Utilities */
.skeuo-bevel-highlight {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.skeuo-groove-track {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* Hamburger Menu Physical Animation - Drop Down (M3 Emphasized Decelerate) */
#hamburger-menu:not(.hidden) {
    animation: menuDropDown var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-emphasized-decelerate) forwards;
}

@keyframes menuDropDown {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   CARD TEXT HIGHLIGHTER & PASTEL COLORS
   ========================================================================== */
/* Touchscreen & selection optimizations for card highlighter */
#question-card, #question-text, #anki-answer-container {
    -webkit-touch-callout: none;
}

#question-body-text, #anki-answer-text {
    -webkit-user-select: text;
    user-select: text;
}

mark.card-hl {
    padding: 0.12em 0.32em;
    margin: 0 -0.05em;
    border-radius: 0.28rem;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    font-weight: inherit;
    line-height: inherit;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s ease, filter 0.2s ease;
}

#text-highlight-popup button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

mark.card-hl:hover {
    filter: brightness(0.96);
}

/* Pastel Yellow */
mark.card-hl-yellow {
    background-color: #fef08a;
    color: #1e293b;
}

/* Pastel Green */
mark.card-hl-green {
    background-color: #bbf7d0;
    color: #1e293b;
}

/* Pastel Blue */
mark.card-hl-blue {
    background-color: #bfdbfe;
    color: #1e293b;
}

/* Pastel Purple */
mark.card-hl-purple {
    background-color: #e9d5ff;
    color: #1e293b;
}

/* Floating Highlight Popup Animation */
#text-highlight-popup:not(.hidden) {
    animation: popupEnter 0.14s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes popupEnter {
    from {
        opacity: 0;
        transform: translate(-50%, 4px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

/* Highlight button state when selection is already marked */
#hl-trigger-btn.is-marked {
    background-color: #fee2e2;
    color: #dc2626;
}
#hl-trigger-btn.is-marked img {
    filter: invert(28%) sepia(91%) saturate(3421%) hue-rotate(345deg) brightness(96%) contrast(92%);
}

/* ==========================================================================
   Material Design 3 Expressive Highlighter Palette & Bounce Animation
   ========================================================================== */

/* The actions bar smooth morphing */
#hl-actions-bar {
    transition: box-shadow 0.25s var(--md-sys-motion-easing-standard),
                background-color 0.25s var(--md-sys-motion-easing-standard);
}

/* Highlighter Trigger Button: Expressive Bounce on Click / Expand */
#hl-trigger-btn {
    transition: transform 0.2s var(--md-sys-motion-easing-spring),
                background-color 0.2s ease,
                color 0.2s ease;
    transform-origin: center center;
}

#hl-trigger-btn.is-active {
    background-color: #fef08a !important;
    color: #713f12 !important;
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.45);
}

#hl-trigger-btn.is-bouncing {
    animation: hlTriggerBounce 0.44s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes hlTriggerBounce {
    0% {
        transform: scale(0.82);
    }
    38% {
        transform: scale(1.26) rotate(-14deg);
    }
    68% {
        transform: scale(0.92) rotate(4deg);
    }
    85% {
        transform: scale(1.06) rotate(-1deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* Palette Container: Spring & Bounce Horizontal Expansion */
#hl-palette {
    flex-shrink: 0;
    white-space: nowrap;
}

#hl-palette.is-expanded {
    display: flex !important;
    animation: hlPaletteExpand 0.36s cubic-bezier(0.34, 1.45, 0.64, 1) forwards;
    transform-origin: left center;
}

@keyframes hlPaletteExpand {
    0% {
        max-width: 0;
        opacity: 0;
        transform: scaleX(0.35) scaleY(0.85);
        overflow: hidden;
    }
    55% {
        max-width: 175px;
        opacity: 1;
        transform: scaleX(1.08) scaleY(1.04);
        overflow: hidden;
    }
    78% {
        transform: scaleX(0.97) scaleY(0.98);
        overflow: hidden;
    }
    100% {
        max-width: 175px;
        opacity: 1;
        transform: scaleX(1) scaleY(1);
        overflow: visible;
    }
}

/* Palette Collapse Animation */
#hl-palette.is-collapsing {
    display: flex !important;
    animation: hlPaletteCollapse 0.18s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transform-origin: left center;
    overflow: hidden !important;
    pointer-events: none;
}

@keyframes hlPaletteCollapse {
    0% {
        max-width: 175px;
        opacity: 1;
        transform: scaleX(1);
    }
    100% {
        max-width: 0;
        opacity: 0;
        transform: scaleX(0.2);
    }
}

/* Vertical Divider pop entrance */
#hl-palette.is-expanded > div:first-child {
    animation: hlDividerPop 0.25s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

@keyframes hlDividerPop {
    0% {
        opacity: 0;
        transform: scaleY(0);
    }
    100% {
        opacity: 1;
        transform: scaleY(1);
    }
}

/* Color Circles: Staggered Spring Bounce */
#hl-palette.is-expanded .hl-color-btn {
    animation: hlColorPopBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    transform-origin: center center;
}

#hl-palette.is-expanded .hl-color-btn[data-color="yellow"] {
    animation-delay: 0.03s;
}

#hl-palette.is-expanded .hl-color-btn[data-color="green"] {
    animation-delay: 0.08s;
}

#hl-palette.is-expanded .hl-color-btn[data-color="blue"] {
    animation-delay: 0.13s;
}

#hl-palette.is-expanded .hl-color-btn[data-color="purple"] {
    animation-delay: 0.18s;
}

@keyframes hlColorPopBounce {
    0% {
        opacity: 0;
        transform: scale(0.15) translateY(6px);
    }
    50% {
        opacity: 1;
        transform: scale(1.28) translateY(-2px);
    }
    75% {
        transform: scale(0.9) translateY(1px);
    }
    88% {
        transform: scale(1.06) translateY(-0.5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Peça ajuda AI Button Shimmer (Light Blue & Purple) */
.hl-ai-shimmering {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #eff6ff 0%, #faf5ff 50%, #eff6ff 100%) !important;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.35), 0 0 3px rgba(59, 130, 246, 0.3) !important;
}

.hl-ai-shimmering::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -150%;
    width: 250%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(147, 197, 253, 0.6) 30%,
        rgba(216, 180, 254, 0.8) 60%,
        transparent 100%
    );
    transform: rotate(25deg);
    animation: hlShimmerOnce 1.0s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

@keyframes hlShimmerOnce {
    0% {
        transform: translateX(0) rotate(25deg);
        opacity: 0;
    }
    30% {
        opacity: 1;
    }
    100% {
        transform: translateX(160%) rotate(25deg);
        opacity: 0;
    }
}

/* Light Blue & Purple Shimmer Skeleton for AI Definition Card */
.hl-shimmer-bg {
    background: linear-gradient(90deg, #f1f5f9 0%, #dbeafe 35%, #f3e8ff 65%, #f1f5f9 100%);
    background-size: 250% 100%;
    animation: hlShimmerSkeleton 1.4s ease-in-out infinite;
}

@keyframes hlShimmerSkeleton {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Definition card enter animation */
#hl-ai-card:not(.hidden):not(.hl-card-collapse-circle) {
    animation: popupEnter 0.16s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* AI Definition Card: Collapse into Bouncing Circle (Subtle & Light Pastel) */
#hl-ai-card.hl-card-collapse-circle {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 50%, #e0e7ff 100%) !important;
    border: 1.5px solid rgba(196, 181, 253, 0.85) !important;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.18), 0 2px 8px rgba(147, 197, 253, 0.22) !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: width 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
                height 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-radius 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
                padding 0.22s ease,
                background 0.22s ease !important;
}

#hl-ai-card.hl-card-collapse-circle > :not(#hl-ai-collapsed-icon) {
    display: none !important;
}

#hl-ai-card.hl-card-collapse-circle #hl-ai-collapsed-icon {
    display: flex !important;
}

@keyframes hlCardBounce {
    0% {
        transform: scale(0.65);
        opacity: 0.85;
    }
    45% {
        transform: scale(1.22);
        opacity: 1;
    }
    75% {
        transform: scale(0.94);
    }
    100% {
        transform: scale(1);
    }
}

#hl-ai-card.hl-card-bounce {
    animation: hlCardBounce 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}

/* AI Chat Container Incoming Pulse (Subtle Pastel Glow) */
@keyframes hlChatIncomingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(192, 132, 252, 0.35);
    }
    50% {
        box-shadow: 0 0 24px 6px rgba(192, 132, 252, 0.22);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(192, 132, 252, 0);
    }
}

.hl-chat-pulse {
    animation: hlChatIncomingPulse 0.6s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    #hl-ai-card.hl-card-bounce,
    #hl-trigger-btn.is-bouncing,
    #hl-palette.is-expanded,
    #hl-palette.is-collapsing,
    #hl-palette.is-expanded .hl-color-btn,
    #hl-palette.is-expanded > div:first-child {
        animation: none !important;
        transition: none !important;
        transform: none !important;
        max-width: none !important;
        opacity: 1 !important;
    }
    .hl-chat-pulse {
        animation: none !important;
    }
}

/* ==========================================================================
   ANKI CARDS MARKDOWN & MATH (KATEX) ENGINE
   ========================================================================== */
#anki-answer-text,
.anki-markdown-content {
    white-space: normal;
    word-break: break-word;
}

#question-body-text {
    white-space: normal;
}

#anki-answer-text p,
#question-body-text p,
.anki-markdown-content p {
    margin-bottom: 0.6rem;
}

#anki-answer-text p:last-child,
#question-body-text p:last-child,
.anki-markdown-content p:last-child {
    margin-bottom: 0;
}

#anki-answer-text h1, #question-body-text h1, .anki-markdown-content h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0.75rem 0 0.5rem;
    color: inherit;
}

#anki-answer-text h2, #question-body-text h2, .anki-markdown-content h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0.65rem 0 0.4rem;
    color: inherit;
}

#anki-answer-text h3, #question-body-text h3, .anki-markdown-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0.5rem 0 0.3rem;
    color: inherit;
}

#anki-answer-text ul, #question-body-text ul, .anki-markdown-content ul {
    list-style-type: disc;
    margin: 0.5rem auto;
    padding-left: 1.5rem;
    text-align: left;
    display: inline-block;
    max-width: 100%;
}

#anki-answer-text ol, #question-body-text ol, .anki-markdown-content ol {
    list-style-type: decimal;
    margin: 0.5rem auto;
    padding-left: 1.5rem;
    text-align: left;
    display: inline-block;
    max-width: 100%;
}

#anki-answer-text li, #question-body-text li, .anki-markdown-content li {
    margin-bottom: 0.25rem;
}

#anki-answer-text table, #question-body-text table, .anki-markdown-content table {
    width: auto;
    max-width: 100%;
    margin: 0.75rem auto;
    border-collapse: collapse;
    font-size: 0.9em;
    text-align: left;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#anki-answer-text th, #question-body-text th, .anki-markdown-content th,
#anki-answer-text td, #question-body-text td, .anki-markdown-content td {
    border: 1px solid rgba(156, 163, 175, 0.35);
    padding: 0.45rem 0.75rem;
}

#anki-answer-text th, #question-body-text th, .anki-markdown-content th {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

#anki-answer-text code, #question-body-text code, .anki-markdown-content code {
    background-color: rgba(0, 0, 0, 0.06);
    padding: 0.15em 0.35em;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.88em;
}

#anki-answer-text pre, #question-body-text pre, .anki-markdown-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.75rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    text-align: left;
    margin: 0.75rem 0;
}

#anki-answer-text blockquote, #question-body-text blockquote, .anki-markdown-content blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 0.75rem;
    margin: 0.5rem 0;
    text-align: left;
    font-style: italic;
    opacity: 0.9;
}

/* KaTeX formula display styling */
.katex-display {
    margin: 0.5rem 0 !important;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.25rem 0;
}

.katex {
    font-size: 1.05em;
    text-rendering: auto;
}

/* ==========================================================================
   AI CHAT ASSISTANT MARKDOWN & MATH ENGINE
   ========================================================================== */
.chat-markdown-content {
    white-space: normal;
    word-break: break-word;
    line-height: 1.55;
    text-align: left;
}

.chat-markdown-content p {
    margin-bottom: 0.5rem;
}

.chat-markdown-content p:last-child {
    margin-bottom: 0;
}

.chat-markdown-content h1,
.chat-markdown-content h2,
.chat-markdown-content h3,
.chat-markdown-content h4 {
    color: inherit;
    font-weight: 700;
    line-height: 1.3;
    margin: 0.75rem 0 0.35rem 0;
}

.chat-markdown-content h1:first-child,
.chat-markdown-content h2:first-child,
.chat-markdown-content h3:first-child,
.chat-markdown-content h4:first-child {
    margin-top: 0;
}

.chat-markdown-content h1 {
    font-size: 1.125rem;
}

.chat-markdown-content h2 {
    font-size: 1.05rem;
}

.chat-markdown-content h3 {
    font-size: 0.95rem;
}

.chat-markdown-content h4 {
    font-size: 0.9rem;
}

.chat-markdown-content ul {
    list-style-type: disc;
    margin: 0.4rem 0 0.5rem 0;
    padding-left: 1.25rem;
    text-align: left;
}

.chat-markdown-content ol {
    list-style-type: decimal;
    margin: 0.4rem 0 0.5rem 0;
    padding-left: 1.25rem;
    text-align: left;
}

.chat-markdown-content li {
    margin-bottom: 0.25rem;
}

.chat-markdown-content li:last-child {
    margin-bottom: 0;
}

.chat-markdown-content ul ul,
.chat-markdown-content ol ol,
.chat-markdown-content ul ol,
.chat-markdown-content ol ul {
    margin: 0.2rem 0;
    padding-left: 1rem;
}

.chat-markdown-content hr {
    border: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
    margin: 0.65rem 0;
}

.chat-markdown-content strong {
    font-weight: 700;
    color: inherit;
}

.chat-markdown-content em {
    font-style: italic;
}

.chat-markdown-content code {
    background-color: rgba(0, 0, 0, 0.08);
    padding: 0.15em 0.35em;
    border-radius: 0.3rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.88em;
}

.chat-markdown-content pre {
    background-color: rgba(0, 0, 0, 0.07);
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    text-align: left;
    margin: 0.5rem 0;
    max-width: 100%;
}

.chat-markdown-content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.85em;
}

.chat-markdown-content blockquote {
    border-left: 3px solid #7c3aed;
    padding-left: 0.65rem;
    margin: 0.45rem 0;
    font-style: italic;
    opacity: 0.9;
}

.chat-markdown-content table {
    width: 100%;
    margin: 0.5rem 0;
    border-collapse: collapse;
    font-size: 0.85em;
    text-align: left;
    display: block;
    overflow-x: auto;
}

.chat-markdown-content th,
.chat-markdown-content td {
    border: 1px solid rgba(0, 0, 0, 0.15);
    padding: 0.35rem 0.6rem;
}

.chat-markdown-content th {
    background-color: rgba(0, 0, 0, 0.06);
    font-weight: 600;
}

.chat-markdown-content a {
    color: #4f46e5;
    text-decoration: underline;
    word-break: break-all;
}

/* ==========================================================================
   FLASHCARD IMAGE SKELETON LOADING PLACEHOLDER & ANIMATION
   ========================================================================== */
@keyframes imageShimmerWave {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.image-loading-placeholder {
    position: relative;
    overflow: hidden;
    background: linear-gradient(
        90deg,
        var(--md-sys-color-surface-container, #e2e8f0) 0%,
        var(--md-sys-color-surface-container-high, #cbd5e1) 50%,
        var(--md-sys-color-surface-container, #e2e8f0) 100%
    );
    background-size: 200% 100%;
    animation: imageShimmerWave 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    border: 1px solid var(--md-sys-color-outline-variant, rgba(0, 0, 0, 0.08));
    border-radius: var(--md-sys-shape-corner-extra-large, 1rem);
}

@media (prefers-reduced-motion: reduce) {
    .image-loading-placeholder {
        animation: none;
        background: var(--md-sys-color-surface-container, #e2e8f0);
    }
}

/* ==========================================================================
   FILL-IN-THE-BLANK INLINE CORRECTION ANIMATIONS
   ========================================================================== */

/* Shake animation for incorrect guess */
@keyframes fillBoxShake {
    0%, 100% {
        transform: translateX(0);
    }
    15% {
        transform: translateX(-7px);
    }
    30% {
        transform: translateX(7px);
    }
    45% {
        transform: translateX(-5px);
    }
    60% {
        transform: translateX(5px);
    }
    75% {
        transform: translateX(-3px);
    }
    90% {
        transform: translateX(3px);
    }
}

.fill-box-shake {
    animation: fillBoxShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Pop & morph animation to green with correct answer */
@keyframes fillBoxPopGreen {
    0% {
        transform: scale(0.88);
        opacity: 0.85;
    }
    45% {
        transform: scale(1.12);
        opacity: 1;
    }
    70% {
        transform: scale(0.97);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.fill-box-pop {
    animation: fillBoxPopGreen 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* Pop & morph animation to yellow with correct answer (focus indicator) */
@keyframes fillBoxPopYellow {
    0% {
        transform: scale(0.88);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
        opacity: 0.85;
    }
    45% {
        transform: scale(1.12);
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.35);
        opacity: 1;
    }
    70% {
        transform: scale(0.97);
        box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
        opacity: 1;
    }
}

.fill-box-pop-yellow {
    animation: fillBoxPopYellow 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* ==========================================================================
   FILL-IN-THE-BLANK RECESSED WELL STYLING
   ========================================================================== */
.fill-blank-input {
    display: inline-block;
    text-align: center;
    font-weight: 700;
    padding: 0.18rem 0.5rem;
    margin: 0 0.25rem;
    border-radius: 0.5rem;
    font-size: 0.95em;
    line-height: inherit;
    vertical-align: baseline;
    min-width: 60px;
    max-width: 240px;
    width: 64px;

    /* Tactile Recessed Well */
    background-color: rgba(243, 244, 246, 0.95);
    border: 1.5px solid rgba(147, 197, 253, 0.8);
    color: #1e293b;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: width 0.15s ease,
                background-color 0.2s ease,
                border-color 0.2s ease,
                box-shadow 0.2s ease,
                color 0.2s ease;
}

.fill-blank-input:focus {
    outline: none;
    background-color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25), inset 0 1px 1px rgba(0, 0, 0, 0.04);
}

.fill-blank-input:read-only {
    cursor: default;
    user-select: text;
}

/* ==========================================================================
   RESPONSE BUTTONS (MULTIPLE CHOICE & GAMEPAD)
   ========================================================================== */

/* Tactile Multiple Choice Options */
.mc-option-btn {
    position: relative;
    border-radius: 0.875rem;
    padding: 0.875rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 0.2s ease,
                border-color 0.2s ease,
                box-shadow 0.2s ease,
                color 0.2s ease;
    border: 1px solid rgba(209, 213, 219, 0.8);
    background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
    color: #1f2937;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    cursor: pointer;
    text-align: left;
    user-select: none;
    touch-action: manipulation;
}

@media (min-width: 640px) {
    .mc-option-btn {
        text-align: center;
    }
}

.mc-option-btn:hover:not(:disabled) {
    border-color: #93c5fd;
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.mc-option-btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.99);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08), inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.mc-option-btn.mc-correct {
    border-color: #10b981 !important;
    background: linear-gradient(180deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px -2px rgba(16, 185, 129, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.35) !important;
}

.mc-option-btn.mc-incorrect {
    border-color: #ef4444 !important;
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px -2px rgba(239, 68, 68, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

/* Multiple Choice Keyboard Number Badge (Bottom Right) */
.mc-key-badge {
    position: absolute;
    bottom: 5px;
    right: 8px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    background: transparent;
    color: #9ca3af;
    border: none;
    pointer-events: none;
    user-select: none;
    transition: all 0.15s ease;
}

.mc-option-label {
    display: block;
    word-break: break-word;
    padding-bottom: 2px;
}

.mc-option-btn:hover:not(:disabled) .mc-key-badge {
    background: transparent;
    color: #2563eb;
    border: none;
}

.mc-option-btn.mc-correct .mc-key-badge,
.mc-option-btn.mc-incorrect .mc-key-badge {
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    border: none;
}

/* Anki Gamepad Rating Buttons (Soft Pastel Aesthetic with Tactile Depth) */
.anki-rating-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.85rem 0.5rem;
    border-radius: 0.875rem;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: transform 0.14s cubic-bezier(0.16, 1, 0.3, 1),
                filter 0.2s ease,
                box-shadow 0.2s ease,
                background-color 0.2s ease;
    border-width: 1.5px;
    border-style: solid;
}

.anki-rating-btn:hover {
    filter: brightness(1.04);
    transform: translateY(-1.5px);
}

.anki-rating-btn:active {
    transform: translateY(1px) scale(0.975);
}

.anki-rating-btn .shortcut-badge {
    font-size: 0.65rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 0.35rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* 1. Errei - Pastel Rose/Red */
.anki-btn-again {
    background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
    border-color: #f87171;
    color: #991b1b;
    box-shadow: 0 2px 6px -1px rgba(239, 68, 68, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.anki-btn-again .shortcut-badge {
    background: rgba(153, 27, 27, 0.12);
    color: #991b1b;
}
.anki-btn-again:hover {
    box-shadow: 0 4px 10px -1px rgba(239, 68, 68, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* 2. Difícil - Pastel Peach/Orange */
.anki-btn-hard {
    background: linear-gradient(180deg, #ffedd5 0%, #fed7aa 100%);
    border-color: #fb923c;
    color: #9a3412;
    box-shadow: 0 2px 6px -1px rgba(249, 115, 22, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.anki-btn-hard .shortcut-badge {
    background: rgba(154, 52, 18, 0.12);
    color: #9a3412;
}
.anki-btn-hard:hover {
    box-shadow: 0 4px 10px -1px rgba(249, 115, 22, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* 3. Médio - Pastel Mint/Green */
.anki-btn-good {
    background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
    border-color: #4ade80;
    color: #166534;
    box-shadow: 0 2px 6px -1px rgba(34, 197, 94, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.anki-btn-good .shortcut-badge {
    background: rgba(22, 101, 52, 0.12);
    color: #166534;
}
.anki-btn-good:hover {
    box-shadow: 0 4px 10px -1px rgba(34, 197, 94, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* 4. Fácil - Pastel Sky/Blue */
.anki-btn-easy {
    background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #60a5fa;
    color: #1e40af;
    box-shadow: 0 2px 6px -1px rgba(59, 130, 246, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.anki-btn-easy .shortcut-badge {
    background: rgba(30, 64, 175, 0.12);
    color: #1e40af;
}
.anki-btn-easy:hover {
    box-shadow: 0 4px 10px -1px rgba(59, 130, 246, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* Tactile Primary Button */
.btn-primary-tactile {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 4px 12px -2px rgba(37, 99, 235, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(29, 78, 216, 0.5);
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary-tactile:hover {
    background: linear-gradient(180deg, #60a5fa 0%, #1d4ed8 100%);
    box-shadow: 0 6px 16px -2px rgba(37, 99, 235, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.btn-primary-tactile:active {
    transform: translateY(1px) scale(0.99);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25), inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Tactile Skip Button (Light Yellow 2.5D Primary CTA for Wrong Answers) */
.btn-skip-tactile,
#next-question-btn {
    background: linear-gradient(180deg, #fef9c3 0%, #fef08a 100%);
    box-shadow: 0 3px 8px -1px rgba(202, 138, 4, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    border: 1.5px solid #facc15;
    color: #713f12;
    touch-action: manipulation;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-skip-tactile:hover,
#next-question-btn:hover {
    background: linear-gradient(180deg, #fefce8 0%, #fde047 100%);
    box-shadow: 0 5px 14px -1px rgba(202, 138, 4, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.98);
    transform: translateY(-1.5px);
    border-color: #eab308;
}

.btn-skip-tactile:active,
#next-question-btn:active {
    transform: translateY(1px) scale(0.99);
    box-shadow: 0 2px 4px rgba(202, 138, 4, 0.2), inset 0 1px 2px rgba(113, 63, 18, 0.12);
}

#next-question-btn img,
.btn-skip-tactile img {
    filter: none;
    opacity: 0.95;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#next-question-btn:hover img,
.btn-skip-tactile:hover img {
    opacity: 1;
    transform: rotate(15deg);
}

/* ==========================================================================
   STREAK COUNTER PILL & SHIMMER ANIMATIONS
   ========================================================================== */

#streak-pill {
    transition: transform 0.25s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

@keyframes streakShimmerUp {
    0% {
        transform: translateY(115%);
        opacity: 0;
    }
    20% {
        opacity: 0.95;
    }
    60% {
        opacity: 0.95;
    }
    100% {
        transform: translateY(-115%);
        opacity: 0;
    }
}

.anim-streak-up {
    animation: streakShimmerUp 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes streakShimmerDown {
    0% {
        transform: translateY(-115%);
        opacity: 0;
    }
    20% {
        opacity: 0.95;
    }
    60% {
        opacity: 0.95;
    }
    100% {
        transform: translateY(115%);
        opacity: 0;
    }
}

.anim-streak-down {
    animation: streakShimmerDown 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes streakPop {
    0% {
        transform: scale(0.92);
    }
    45% {
        transform: scale(1.15);
    }
    75% {
        transform: scale(0.98);
    }
    100% {
        transform: scale(1);
    }
}

.anim-streak-pop {
    animation: streakPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* ==========================================================================
   ACCESSIBILITY: PREFERS-REDUCED-MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .modal-overlay:not(.hidden) > div,
    .modal-overlay:not(.hidden) > form > div,
    #hamburger-menu:not(.hidden),
    #text-highlight-popup:not(.hidden),
    .card-shake,
    .fill-box-shake,
    .fill-box-pop,
    .fill-box-pop-yellow,
    .anim-card-to-back,
    .anim-streak-up,
    .anim-streak-down,
    .anim-streak-pop,
    .card-enter-anim,
    .m3-card-elastic-in,
    .m3-card-elastic-collision-hit,
    .m3-dropdown-open,
    .m3-dropdown-close,
    .m3-select-chevron,
    .m3-tab-panel-enter-forward,
    .m3-tab-panel-enter-backward,
    .m3-fade-through-enter,
    .m3-fade-through-exit,
    .m3-dialog-enter,
    .card-shockwave-pulse,
    .completion-ripple-wave,
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none !important;
        transform: none !important;
    }
}

/* Deck Completion Shockwave Card Pulse */
@keyframes cardShockwavePulse {
    0% { transform: scale(1); }
    18% { transform: scale(1.032); }
    34% { transform: scale(0.988); }
    50% { transform: scale(1.006); }
    100% { transform: scale(1); }
}

.card-shockwave-pulse {
    animation: cardShockwavePulse 0.65s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform;
}

/* Deck Completion Translucent GPU-Accelerated Ripple Waves */
.completion-ripple-wave {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform, opacity;
    transform-origin: center center;
}

#deck-completion-view:not(.hidden) {
    animation: completionFadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    will-change: transform, opacity;
}

@keyframes completionFadeUp {
    0% {
        opacity: 0;
        transform: scale(0.97);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================================================== */
/* POMODORO: SAMSUNG ONE UI HEADS-UP NOTIFICATION & M3 EXPRESSIVE BREAK STATES */
/* ========================================================================== */

/* --- Pomodoro Heads-up Prompt Dialog (Samsung One UI) --- */
#pomodoro-prompt-dialog {
    will-change: transform, opacity;
}

/* --- Pomodoro Break Overlay: Running State --- */
#pomodoro-break-overlay.pomodoro-state-running #pomodoro-break-card {
    border-color: rgba(59, 130, 246, 0.25);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

#pomodoro-break-overlay.pomodoro-state-running #pomodoro-break-icon-box {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    animation: pomodoroCalmBreathing 4s infinite ease-in-out;
}

#pomodoro-break-overlay.pomodoro-state-running #pomodoro-break-status-badge {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
}

@media (prefers-color-scheme: dark) {
    #pomodoro-break-overlay.pomodoro-state-running #pomodoro-break-status-badge {
        color: #60a5fa;
        background: rgba(59, 130, 246, 0.2);
    }
}

#pomodoro-break-overlay.pomodoro-state-running #pomodoro-break-timer-box {
    background: var(--md-sys-color-surface-container-high);
    border-color: var(--md-sys-color-outline-variant);
}

#pomodoro-break-overlay.pomodoro-state-running #pomodoro-break-countdown {
    color: #2563eb;
}

@media (prefers-color-scheme: dark) {
    #pomodoro-break-overlay.pomodoro-state-running #pomodoro-break-countdown {
        color: #60a5fa;
    }
}

#pomodoro-break-overlay.pomodoro-state-running #pomodoro-resume-btn {
    height: 48px;
    border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

/* --- Pomodoro Break Overlay: DONE State (Distance Attention & M3 Expressive) --- */
#pomodoro-break-overlay.pomodoro-state-done {
    background-color: rgba(3, 7, 18, 0.88);
}

#pomodoro-break-overlay.pomodoro-state-done #pomodoro-done-ambient {
    opacity: 1;
}

#pomodoro-break-overlay.pomodoro-state-done #pomodoro-break-card {
    border: 2px solid #10b981;
    box-shadow: 0 0 60px 20px rgba(16, 185, 129, 0.4), 0 25px 60px rgba(0, 0, 0, 0.7);
    transform: scale(1.025);
    animation: pomodoroCardDonePulse 3s infinite ease-in-out;
}

#pomodoro-break-overlay.pomodoro-state-done #pomodoro-icon-ping {
    display: block;
}

#pomodoro-break-overlay.pomodoro-state-done #pomodoro-break-icon-box {
    background: linear-gradient(135deg, #10b981 0%, #0d9488 100%);
    color: #ffffff;
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.55);
    animation: pomodoroIconDoneShake 2s infinite ease-in-out;
}

#pomodoro-break-overlay.pomodoro-state-done #pomodoro-break-status-badge {
    background: rgba(16, 185, 129, 0.16);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

@media (prefers-color-scheme: dark) {
    #pomodoro-break-overlay.pomodoro-state-done #pomodoro-break-status-badge {
        color: #34d399;
        background: rgba(16, 185, 129, 0.22);
    }
}

#pomodoro-break-overlay.pomodoro-state-done #pomodoro-break-title {
    color: var(--md-sys-color-on-surface);
}

#pomodoro-break-overlay.pomodoro-state-done #pomodoro-break-timer-box {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(13, 148, 136, 0.2) 100%);
    border: 2px solid rgba(16, 185, 129, 0.5);
    box-shadow: inset 0 0 24px rgba(16, 185, 129, 0.18);
}

#pomodoro-break-overlay.pomodoro-state-done #pomodoro-break-countdown {
    color: #10b981;
    text-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
    letter-spacing: 0.08em;
}

/* Material 3 Expressive Extra-Large Hero Button */
#pomodoro-break-overlay.pomodoro-state-done #pomodoro-resume-btn {
    height: 60px;
    border-radius: var(--md-sys-shape-corner-full);
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: 0.035em;
    box-shadow: 0 12px 35px rgba(16, 185, 129, 0.48);
    animation: pomodoroBtnGlowPulse 2.2s infinite ease-in-out;
}

#pomodoro-break-overlay.pomodoro-state-done #pomodoro-resume-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 16px 42px rgba(16, 185, 129, 0.65);
}

/* Radar Beacon Waves & Ambient Animations */
.pomodoro-beacon-ring {
    position: absolute;
    animation: pomodoroBeaconExpand 3s infinite cubic-bezier(0.1, 0.8, 0.3, 1);
}

.pomodoro-beacon-ring.ring-delay {
    animation-delay: 1.5s;
}

@keyframes pomodoroBeaconExpand {
    0% {
        transform: scale(0.6);
        opacity: 0.9;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

@keyframes pomodoroCardDonePulse {
    0%, 100% {
        box-shadow: 0 0 50px 15px rgba(16, 185, 129, 0.35), 0 25px 60px rgba(0, 0, 0, 0.7);
    }
    50% {
        box-shadow: 0 0 85px 30px rgba(16, 185, 129, 0.6), 0 25px 60px rgba(0, 0, 0, 0.7);
    }
}

@keyframes pomodoroBtnGlowPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 10px 30px rgba(16, 185, 129, 0.45);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 16px 40px rgba(16, 185, 129, 0.7);
    }
}

@keyframes pomodoroIconDoneShake {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.12) rotate(-5deg); }
    30% { transform: scale(1.12) rotate(5deg); }
    45% { transform: scale(1); }
}

@keyframes pomodoroCalmBreathing {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 14px rgba(59, 130, 246, 0.15);
    }
    50% {
        transform: scale(1.04);
        box-shadow: 0 6px 22px rgba(59, 130, 246, 0.3);
    }
}



