    /* 懒加载淡入动画 */
    .lazy-load {
      opacity: 0;
      transform: translateY(20px);
      transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    }
    .lazy-load.visible {
      opacity: 1;
      transform: translateY(0);
    }

    /* 点击涟漪效果 */
    .clickable {
      position: relative;
      overflow: hidden;
      cursor: pointer;
    }
    @keyframes ripple {
      to {
        transform: scale(4);
        opacity: 0;
      }
    }

    /* 点击缩放效果 */
    .click-scale {
      transition: transform 0.2s ease;
    }
    .click-scale:active {
      transform: scale(0.98);
    }
  

    /* VIP Loading Animation */
/* Loading Animation */
        .loading-page {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--bg-dark);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
            transition: opacity 0.5s ease;
        }
        
        .loading-page.hidden {
            opacity: 0;
            pointer-events: none;
        }
        
        .loader {
            width: 50px;
            height: 50px;
            border: 3px solid var(--border-subtle);
            border-top-color: var(--primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        /* 懒加载淡入动画 */
        .lazy-section {
            opacity: 0;
            transform: translateY(40px);
            transition: opacity 0.8s ease, transform 0.8s ease;
        }
        
        .lazy-section.visible {
            opacity: 1;
            transform: translateY(0);
        }
</style>

/* ══════════════════════════════════════════════════════════════
   HEALING GARDEN — Premium Mental Wellness UI
   Typography: Fraunces (Display) & Plus Jakarta Sans (Body)
   ══════════════════════════════════════════════════════════════ */

/* ─── Font initialization ─── */
html { font-family: system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif; }

/* ─── iOS 触摸修复 ─── */
* {
  -webkit-tap-highlight-color: transparent;
}

/* ─── Design Tokens ─── */
/* ─── Solarized Light — gentle, low-glare, WCAG-compliant ─── */
:root {
  --hue: 260;
  --primary: #8B5CF6;
  --primary-light: #A78BFA;
  --bg: #F5FAFC;
  --bg-primary: #F5FAFC;
  --bg-secondary: #EBF3F5;
  --bg-tertiary: #DDE8ED;
  --text-primary: #2D1F33;
  --text-secondary: #5A435A;
  --text-muted: #7D6578;
  --accent: #4A90A4;           /* 蓝色主色 */
  --accent-light: #7AB8C9;     /* 浅蓝 */
  --accent-dark: #2E6B7D;
  --accent-warm: #5B9BD5;       /* 亮蓝 */
  --accent-glow: rgba(74, 144, 164, 0.12);
  --border: rgba(155, 89, 182, 0.12);
  --shadow-sm: 0 1px 3px rgba(155, 89, 182, 0.06), 0 1px 2px rgba(155, 89, 182, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(155, 89, 182, 0.10), 0 2px 8px -2px rgba(155, 89, 182, 0.06);
  --shadow-lg: 0 20px 48px -8px rgba(155, 89, 182, 0.16), 0 8px 16px -4px rgba(232, 90, 155, 0.08);
  --disclaimer-bg: #F5E6F0;
  --disclaimer-border: #9B59B6;
  --privacy-bg: #EBE4F5;
  --privacy-border: #7D3C98;
  --resources-bg: #EDE4EE;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-premium: cubic-bezier(0.23, 1, 0.32, 1);
  --font-display: 'PingFang SC', 'Source Han Serif SC', 'STSong', 'SimSun', 'Microsoft YaHei', ui-serif, serif;
  --font-body: 'PingFang SC', 'Source Han Sans SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --radius: 24px;
  --radius-sm: 14px;
  --radius-xs: 8px;
  --fs-h1: clamp(1.75rem, 4.5vw, 2.5rem);
  --fs-h2: clamp(1.2rem, 3vw, 1.6rem);
  --fs-body: clamp(1rem, 2vw, 1.125rem); /* WCAG 16px min for body text */
  /* ── 通用组件变量 ── */
  --card-radius: var(--radius-sm);
  --card-shadow: var(--shadow-md);
  --card-border: 1px solid var(--border);
  --card-padding: clamp(1rem, 3vw, 1.5rem);
  --btn-radius: var(--radius-xs);
  --btn-padding: 0.5rem 1rem;
  --btn-font: var(--font-body);
  --banner-radius: var(--radius-sm);
  --banner-shadow: var(--shadow-sm);
}

/* ─── Dark Mode — Warm Evening ─── */
html[data-theme="dark"] {
  --hue: 260;
  --primary: #A78BFA;
  --primary-light: #C4B5FD;
  --bg: #1A1520;
  --bg-primary: #1A1520;
  --bg-secondary: #231D28;
  --bg-tertiary: #2D2535;
  --text-primary: #EEE4ED;
  --text-secondary: #B8A8BF;
  --text-muted: #8E7A92;
  --accent: #4A90A4;
  --accent-light: #7AB8C9;
  --accent-dark: #2E6B7D;
  --accent-warm: #5B9BD5;
  --accent-glow: rgba(74, 144, 164, 0.14);
  --border: rgba(238, 228, 237, 0.08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 20px 48px -8px rgba(0, 0, 0, 0.42);
  --disclaimer-bg: #2A2030;
  --disclaimer-border: #BB77CE;
  --privacy-bg: #202230;
  --privacy-border: #BB77CE;
  --resources-bg: #202230;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --hue: 260; --primary: #A78BFA; --primary-light: #C4B5FD; --bg: #1A1520; --bg-primary: #1A1520; --bg-secondary: #231D28; --bg-tertiary: #2D2535;
    --text-primary: #EEE4ED; --text-secondary: #B8A8BF; --text-muted: #8E7A92;
    --accent: #4A90A4; --accent-light: #7AB8C9; --accent-dark: #2E6B7D;
    --accent-warm: #5B9BD5;
    --accent-glow: rgba(74, 144, 164, 0.14);
    --border: rgba(238, 228, 237, 0.08);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 20px 48px -8px rgba(0, 0, 0, 0.42);
    --disclaimer-bg: #2A2030; --disclaimer-border: #BB77CE;
    --privacy-bg: #202230; --privacy-border: #BB77CE; --resources-bg: #202230;
  }
}

/* ─── Base ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background 0.4s var(--ease-premium), color 0.3s ease;
  background-image:
    radial-gradient(ellipse at 0% 0%, var(--accent-glow) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(188, 132, 108, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
}
.container { max-width: 920px; margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 3vw, 1.5rem) 3rem; }

/* ─── Immersive Mode Modifications ─── */
body.immersive-mode .app-header,
body.immersive-mode .tabs,
body.immersive-mode .app-footer {
  display: none !important;
}
body.immersive-mode .container {
  padding-top: clamp(1rem, 2vw, 1.5rem);
  max-width: 840px; /* Sensibly limit width for better reading line lengths */
}

/* ─── Skeleton Loading Animations ─── */
@keyframes shine {
  to { background-position-x: -200%; }
}
.skeleton {
  background: var(--bg-tertiary);
  background: linear-gradient(110deg, var(--bg-tertiary) 8%, var(--bg-secondary) 18%, var(--bg-tertiary) 33%);
  background-size: 200% 100%;
  animation: 1.5s shine linear infinite;
  border-radius: var(--radius-xs);
}
.skeleton-line-lg { height: 32px; width: 80%; margin-bottom: 32px; }
.skeleton-line-sm { height: 16px; width: 40%; margin-bottom: 24px; }
.skeleton-option { height: 60px; width: 100%; margin-bottom: 16px; border-radius: var(--radius-sm); }

/* ─── Accessibility ─── */
.skip-link {
  position: absolute; top: -100%; left: 1rem;
  background: var(--accent); color: white;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  font-weight: 600; text-decoration: none; z-index: 10000;
}
.skip-link:focus { top: 1rem; }
*:focus-visible {
  outline: 3px solid var(--accent-light);
  outline-offset: 3px;
  border-radius: 4px;
}
.option:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ─── Header ─── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: nowrap; gap: 0.75rem; margin-bottom: 1.25rem;
  padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}
.app-header .title-group { flex: 1; min-width: 0; }
.app-header h1 {
  font-family: var(--font-display); font-size: clamp(1.15rem, 3vw, 1.5rem);
  font-weight: 500; font-optical-sizing: auto;
  color: var(--text-primary); letter-spacing: -0.02em; cursor: pointer;
  line-height: 1.2; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header p {
  color: var(--text-muted); font-size: 0.85rem;
  margin: 0.1rem 0 0 0; font-weight: 300; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.header-controls {
  display: flex; flex-wrap: nowrap; align-items: center;
  gap: 0.35rem; margin-top: 0; flex-shrink: 0;
}
@media (max-width: 520px) {
  .app-header { gap: 0.4rem; }
  .app-header h1 { font-size: clamp(1rem, 4vw, 1.3rem); }
  .app-header p { font-size: 0.78rem; }
  .lang-select-wrapper { max-width: 90px; }
  .lang-select-btn { min-height: 32px; font-size: 0.8rem; }
  .theme-toggle {
    min-width: 34px; min-height: 34px;
    padding: 0.25rem;
    border-width: 1px;
    font-size: 0.95rem;
  }
}
@media (max-width: 380px) {
  .app-header h1 { font-size: clamp(0.95rem, 4.5vw, 1.15rem); }
  .app-header p { font-size: 0.72rem; }
  .lang-select-wrapper { max-width: 80px; }
  .lang-select-btn { min-height: 28px; font-size: 0.75rem; }
  .theme-toggle {
    min-width: 30px; min-height: 30px;
    font-size: 0.85rem;
  }
}

/* ─── Immersive Header (Test Title Bar) ─── */
.immersive-header { display: none; }
body.immersive-mode .immersive-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 1.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border);
  animation: fadeUp 0.5s var(--ease-premium);
}
.test-title-bar { display: flex; align-items: center; gap: 0.75rem; }
.test-icon { font-size: clamp(1.4rem, 4vw, 1.8rem); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-xs); width: 44px; height: 44px; background: var(--accent-glow); }
.imm-title { font-family: var(--font-display); font-size: clamp(1.2rem, 3.5vw, 1.5rem); font-weight: 500; margin: 0; color: var(--text-primary); letter-spacing: -0.01em; }
.btn-close-test {
  background: var(--bg-tertiary); color: var(--text-secondary);
  border: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.15rem; transition: all 0.2s var(--ease-premium); font-weight: bold;
}
.btn-close-test:hover, .btn-close-test:focus-visible { 
  background: #A65D5720; color: #A65D57; transform: scale(1.05); 
}

/* ─── Language Selector (Custom Dropdown) ─── */
.lang-select-wrapper {
  position: relative;
  min-height: 36px;
  max-width: 160px;
  z-index: 1000;
}
.lang-select-btn {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 4px;
  width: 100%;
  min-height: 36px;
  padding: 0.2rem 0.35rem 0.2rem 0.2rem;
  border: none; border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body); font-size: 0.9rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.3s var(--ease-premium);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.lang-select-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; unicode-bidi: isolate; }
.lang-select-arrow { flex-shrink: 0; transition: transform 0.25s ease; }
.lang-select-wrapper.open .lang-select-arrow { transform: rotate(180deg); }
.lang-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  max-width: 260px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
  border-radius: var(--card-radius, 10px);
  background: var(--bg-secondary, #fff);
  box-shadow: var(--shadow-lg, 0 20px 48px -8px rgba(0,0,0,0.18));
  list-style: none;
  z-index: 2000;
  -webkit-overflow-scrolling: touch;
}
.lang-dropdown.show { display: block; animation: langDropIn 0.15s ease-out; }
@keyframes langDropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.lang-dropdown li {
  padding: 7px 14px;
  font-family: var(--font-body); font-size: 0.85rem;
  color: var(--text-primary, #333);
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
  direction: ltr; unicode-bidi: isolate;
  -webkit-tap-highlight-color: transparent;
}
.lang-dropdown li:hover,
.lang-dropdown li:focus { background: var(--accent-light, rgba(155,89,182,0.1)); }
.lang-dropdown li.active { background: var(--accent-light, rgba(155,89,182,0.12)); color: var(--accent, #9B59B6); font-weight: 600; }

/* ─── Theme Toggle ─── */
.theme-toggle {
  min-width: 42px; min-height: 42px;
  padding: 0.35rem; border: 1.5px solid var(--border);
  border-radius: 10px; background: transparent;
  cursor: pointer; font-size: 1.125rem;
  transition: all 0.3s var(--ease-premium);
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--accent-light); background: var(--accent-glow); }

/* ─── Tabs ─── */
.tabs {
  display: flex; gap: 0.3rem; background: var(--bg-tertiary);
  padding: 5px; border-radius: var(--radius-sm); margin-bottom: 1.5rem;
}
.tab {
  flex: 1; min-height: 48px; /* Touch target */
  padding: 0.6rem 0.85rem; border: none; background: transparent;
  font-family: var(--font-body); font-size: 1rem; font-weight: 500; /* WCAG Size */
  color: var(--text-muted); cursor: pointer; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s var(--ease-premium);
}
.tab:hover:not(.active) { color: var(--text-primary); }
.tab.active {
  background: var(--bg-secondary); color: var(--text-primary);
  box-shadow: var(--shadow-sm); font-weight: 600;
}
.vip-link {
  background: linear-gradient(135deg, #f472b6 0%, #c084fc 50%, #7c3aed 100%);
  color: white !important;
  font-weight: 700;
  margin-left: 0.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(192, 132, 252, 0.45), 0 0 20px rgba(244, 114, 182, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
  animation: vipPulse 2.5s ease-in-out infinite;
}
@keyframes vipPulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(192, 132, 252, 0.45), 0 0 20px rgba(244, 114, 182, 0.2); }
  50% { box-shadow: 0 2px 20px rgba(192, 132, 252, 0.65), 0 0 30px rgba(244, 114, 182, 0.4); }
}
.vip-link::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
  animation: vipShine 3s ease-in-out infinite;
}
@keyframes vipShine {
  0%, 100% { transform: translateX(-100%) rotate(25deg); }
  50% { transform: translateX(100%) rotate(25deg); }
}
.vip-link:hover {
  background: linear-gradient(135deg, #c4b5fd 0%, #8b5cf6 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(118, 75, 162, 0.5);
}

/* ─── Screens ─── */
.screen { display: none; }
.screen.active { display: block; animation: fadeUp 0.5s var(--ease-premium); }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Category Index Nav (sticky chip bar) ─── */
.cat-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.7rem 0.25rem;
  margin: 0 -0.25rem 1rem -0.25rem;
  background: transparent;
  border-bottom: none;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  scroll-behavior: smooth;
  transition: scrollbar-color 0.3s ease;
}
/* 吸附状态：模糊背景铺满 + 阴影 */
.cat-nav.stuck {
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  padding-left: calc(50vw - 50%);
  padding-right: calc(50vw - 50%);
  background: rgba(245, 250, 252, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
/* 暗色模式吸附状态 */
html[data-theme="dark"] .cat-nav.stuck {
  background: rgba(26, 21, 32, 0.85);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .cat-nav.stuck {
    background: rgba(26, 21, 32, 0.85);
  }
}
.cat-nav:hover,
.cat-nav.scrolling {
  scrollbar-color: var(--border) transparent;
}
.cat-nav::-webkit-scrollbar { height: 1px; transition: height 0.3s ease; }
.cat-nav:hover::-webkit-scrollbar,
.cat-nav.scrolling::-webkit-scrollbar { height: 3px; }
.cat-nav::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; transition: background 0.3s ease; }
.cat-nav:hover::-webkit-scrollbar-thumb,
.cat-nav.scrolling::-webkit-scrollbar-thumb { background: var(--border); }
.cat-nav::-webkit-scrollbar-track { background: transparent; }
.cat-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.cat-chip:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--accent-light);
}
.cat-chip:focus-visible {
  outline: 3px solid var(--accent-light);
  outline-offset: 2px;
}
.cat-chip[aria-current="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.cat-chip-count {
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

/* ─── Test Grid ─── */
.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: clamp(0.85rem, 2.5vw, 1.35rem);
  scroll-margin-top: 4rem;
}
.category-header {
  scroll-margin-top: 5rem;
}

.category-header {
  opacity: 0; animation: cardReveal 0.4s var(--ease-premium) forwards;
}
.category-header:first-child { margin-top: 0 !important; }
.category-header h2 {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(1rem, 2.5vw, 1.15rem); color: var(--accent);
  border-bottom: 1px solid var(--border); padding-bottom: 0.4rem;
  letter-spacing: -0.01em; margin-bottom: 0.4rem;
}

.test-card {
  background: var(--bg-secondary); border-radius: var(--card-radius);
  padding: var(--card-padding); box-shadow: var(--card-shadow); cursor: pointer;
  transition: all 0.5s var(--ease-premium);
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
  opacity: 0; transform: translateY(14px);
  animation: cardReveal 0.5s var(--ease-premium) forwards;
}
@keyframes cardReveal {
  to { opacity: 1; transform: translateY(0); }
}
.test-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 150% 150% at 0% 0%, var(--card-accent, var(--accent)) 0%, transparent 60%);
  opacity: 0; transition: opacity 0.5s var(--ease-premium);
}
.test-card::after {
  content: ''; position: absolute; bottom: -40px; right: -40px;
  width: 120px; height: 120px;
  background: var(--card-accent, var(--accent));
  opacity: 0; border-radius: 50%;
  transition: all 0.6s var(--ease-premium);
}
.test-card:hover::before { opacity: 0.06; }
.test-card:hover::after { opacity: 0.04; transform: scale(1.5); }
@media (hover: hover) {
  .test-card:hover {
    transform: translateY(-8px); box-shadow: var(--shadow-lg);
    border-color: var(--card-accent, var(--accent));
  }
}
.test-card:active { transform: translateY(-2px) scale(0.99); }
.test-card .card-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.test-card-icon-wrapper {
  display: inline-flex; align-items: center; gap: 0.5rem; margin-bottom: 0.15rem;
}
.test-card-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.15rem; flex-shrink: 0;
  transition: all 0.4s var(--ease-premium);
}
.test-card:hover .test-card-icon {
  transform: rotate(-5deg) scale(1.05);
}
.test-card h3 {
  font-family: var(--font-display); font-size: clamp(0.95rem, 2vw, 1.05rem);
  font-weight: 500; margin-bottom: 0.15rem;
  line-height: 1.3; letter-spacing: -0.01em; color: var(--text-primary);
}
.test-card .card-abbr {
  font-size: 0.75rem; font-weight: 700; color: var(--accent-warm);
  text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--accent-warm); color: #fff; padding: 0.15rem 0.45rem;
  border-radius: 4px; white-space: nowrap;
}
.test-card p {
  font-size: 0.875rem; color: var(--text-muted); line-height: 1.5;
}
.test-card .card-meta {
  font-size: 0.8rem; color: var(--text-muted); margin-top: 0.5rem;
  display: flex; gap: 0.7rem; font-weight: 500;
  padding-top: 0.5rem; border-top: 1px solid var(--border);
}

/* ─── Resume Banner (Card Style) ─── */
.resume-banner {
  background: var(--bg-secondary); border-radius: var(--card-radius);
  padding: var(--card-padding); box-shadow: var(--card-shadow);
  border: var(--card-border); position: relative; overflow: hidden;
  margin-bottom: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap; animation: cardReveal 0.5s var(--ease-premium) forwards;
}
.resume-banner::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 150% 150% at 0% 0%, var(--accent) 0%, transparent 60%);
  opacity: 0.08;
}
.resume-banner::after {
  content: ''; position: absolute; bottom: -30px; right: -30px;
  width: 100px; height: 100px;
  background: var(--accent); opacity: 0.06; border-radius: 50%;
}
.resume-banner > p {
  flex: 1; min-width: 200px;
  font-family: var(--font-display); font-size: clamp(0.95rem, 2.2vw, 1.1rem);
  font-weight: 500; color: var(--text-primary); line-height: 1.4;
  margin: 0; position: relative; z-index: 1;
}
.resume-banner-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background-color: hsl(var(--hue), 60%, 96%);
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0; position: relative; z-index: 1;
  box-shadow: 0 4px 12px -2px rgba(74,144,164,0.25);
}
.resume-banner .btn-primary {
  position: relative; z-index: 1;
  min-height: 42px; padding: var(--btn-padding); font-size: 0.95rem;
  flex-shrink: 0;
}
.resume-banner .btn-ghost {
  position: relative; z-index: 1;
  min-height: 42px; width: 42px; padding: 0;
  font-size: 1rem; flex-shrink: 0;
  background: transparent; color: var(--text-muted);
  border: 1px solid transparent; border-radius: var(--btn-radius);
  transition: all 0.3s var(--ease-premium);
}
.resume-banner .btn-ghost:hover {
  background: var(--bg-tertiary); color: var(--text-secondary);
  border-color: var(--border);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px;
  padding: var(--btn-padding); font-family: var(--btn-font); font-size: 1rem; /* WCAG size */
  font-weight: 600; border: none; border-radius: var(--btn-radius); cursor: pointer;
  transition: all 0.35s var(--ease-premium);
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--accent); color: white;
  box-shadow: 0 6px 20px -4px rgba(74, 103, 65, 0.3);
}
.btn-primary:hover {
  background: var(--accent-dark); transform: translateY(-2px);
  box-shadow: 0 10px 28px -4px rgba(74, 103, 65, 0.35);
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-outline {
  background: transparent; color: var(--accent); border: 2px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-glow); transform: translateY(-1px); }
.btn-outline:active { transform: scale(0.98); }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  padding: 0.5rem 0.85rem; font-size: 1rem; /* WCAG size */
}
.btn-ghost:hover { color: var(--accent); }
.btn-ghost:active { transform: scale(0.98); }

/* ─── Welcome Card ─── */
.welcome-card {
  background: transparent; border-radius: var(--radius);
  padding: clamp(1.75rem, 5vw, 3rem) clamp(1.25rem, 4vw, 2.5rem);
  box-shadow: none; text-align: center;
  border: none;
}
.welcome-icon {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem; font-size: 1.75rem;
}
.welcome-card h2 {
  font-family: var(--font-display); font-size: var(--fs-h2);
  font-weight: 500; margin-bottom: 0.85rem; letter-spacing: -0.02em; color: var(--text-primary);
}
.welcome-card p {
  color: var(--text-secondary); font-size: 1rem; margin-bottom: 0.5rem; line-height: 1.7; /* WCAG size */
}
.disclaimer {
  background: var(--disclaimer-bg); border-left: 3px solid var(--disclaimer-border);
  padding: 1rem 1.15rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1.25rem 0; text-align: left; font-size: 1rem; /* WCAG size */
  color: var(--text-secondary); line-height: 1.65;
}
.copyright-info {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  opacity: 0.85;
}

/* ─── Progress ─── */
.progress-section { margin-bottom: 1.75rem; }
.progress-info {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.6rem; font-size: 1rem; color: var(--text-muted); font-weight: 600; /* WCAG size */
}
.progress-bar {
  width: 100%; height: 8px; background: var(--bg-tertiary);
  border-radius: 100px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--accent-light), var(--accent));
  transition: width 0.5s var(--ease-out); position: relative;
}
.progress-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 2.5s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ─── Question Card (Immersive/Zen Mode) ─── */
.question-card {
  background: transparent; border: none; box-shadow: none; /* Removed card box for better immersion */
  min-height: 320px; display: flex; flex-direction: column;
  padding: 0;
}
.question-number {
  font-size: 1rem; font-weight: 700; text-transform: uppercase; /* WCAG size */
  letter-spacing: 0.12em; margin-bottom: 0.75rem;
  color: var(--accent-warm);
}
.question-title {
  font-family: var(--font-display); font-size: clamp(1.4rem, 4.5vw, 1.85rem); /* Much bigger for readability */
  font-weight: 500;
  margin-bottom: 2.25rem; color: var(--text-primary); line-height: 1.6;
  letter-spacing: -0.01em;
}

/* ─── Options Animation & Layout ─── */
#question-area { opacity: 1; transition: opacity 0.2s ease; }
#question-area.fading { opacity: 0; transition: opacity 0.18s ease; }
#question-area.fade-in { animation: qFadeIn 0.22s ease forwards; }
@keyframes qFadeIn { from { opacity: 0; } to { opacity: 1; } }

.options { display: flex; flex-direction: column; gap: 0.85rem; flex: 1; }
.option {
  display: flex; align-items: center; gap: 1rem;
  min-height: 56px; /* Guaranteed touch target */
  padding: 1.15rem 1.25rem; border: 2px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.25s var(--ease-premium); font-size: 1.1rem; /* Bigger for readability */
  line-height: 1.5; color: var(--text-secondary);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.option:hover {
  border-color: var(--accent-light); background: var(--accent-glow);
  box-shadow: var(--shadow-md);
}
.option:active {
  transform: scale(0.99);
  background: var(--accent-glow);
}
.option.selected {
  /* Minimal style: no background change, no transform, no font-weight */
  border-color: var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  /* Only keep: radio dot fills (below) */
}
.option-radio {
  width: 24px; height: 24px; min-width: 24px;
  border: 2px solid var(--border); border-radius: 50%;
  transition: all 0.25s var(--ease-premium);
  display: flex; align-items: center; justify-content: center;
}
.option.selected .option-radio {
  border-color: var(--accent); background: var(--accent);
}
.option.selected .option-radio::after {
  content: ''; width: 8px; height: 8px; background: white;
  border-radius: 50%; /* no animation */
}
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }

/* Keyboard navigation visual hints */
.key-badge { display: none; }
@media (min-width: 768px) and (hover: hover) {
  .key-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border: 1.5px solid var(--border); 
    border-radius: 6px; font-size: 0.8rem; color: var(--text-muted); 
    margin-left: auto; font-family: var(--font-body); font-weight: 600;
    background: var(--bg-tertiary); transition: all 0.2s;
  }
  .option:hover .key-badge { background: var(--bg-primary); border-color: var(--accent-light); }
  .option.selected .key-badge { opacity: 0.4; }
  .option.kb-focused {
    border-color: var(--accent-light);
    background: var(--accent-glow);
    box-shadow: 0 0 0 2px var(--accent-glow);
  }
  .option.kb-focused .key-badge {
    background: var(--accent); color: white; border-color: var(--accent);
  }
  
  .keyboard-hint {
    display: block; text-align: center; font-size: 0.9rem; 
    color: var(--text-muted); margin-top: 2rem; opacity: 0.85;
  }
}
@media (hover: none) or (max-width: 767px) {
  .keyboard-hint { display: none; }
}

/* Pulse animation for hard keyboard selection */
@keyframes pulsePress {
  0% { transform: scale(1); box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { transform: scale(0.97); box-shadow: 0 0 0 12px transparent; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}
.option.pressed {
  animation: pulsePress 0.3s var(--ease-spring);
  border-color: var(--accent); background: var(--accent-glow);
}
@keyframes pulseHint {
  0%, 100% { transform: scale(1); box-shadow: var(--shadow-sm); }
  50% { transform: scale(1.03); box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-md); }
}
.btn.pulse-hint {
  animation: pulseHint 1.2s ease-in-out 2;
}

kbd {
  background: var(--bg-secondary); padding: 0.15rem 0.45rem;
  border: 1.5px solid var(--border); border-radius: 4px; border-bottom-width: 2.5px;
  font-family: inherit; font-size: 0.85em; font-weight: 700;
  color: var(--text-secondary); margin: 0 0.15em; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.question-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
}
.question-content { animation: slideIn 0.4s var(--ease-out); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─── Results (Empathetic) ─── */
.results-card {
  background: var(--bg-secondary); border-radius: var(--radius);
  padding: clamp(2rem, 5vw, 3rem) clamp(1.25rem, 4vw, 2.5rem);
  box-shadow: var(--shadow-md); text-align: center;
  border: 1px solid var(--border);
}
.score-circle {
  width: 120px; height: 120px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; margin: 0 auto 1.25rem;
  animation: scaleIn 0.6s var(--ease-spring);
}
@keyframes scaleIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.score-number {
  font-family: var(--font-display); font-size: 2.5rem; color: white;
  line-height: 1; font-weight: 400;
}
.score-label {
  font-size: 0.875rem; color: rgba(255,255,255,0.85); /* WCAG size */
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em;
}
.score-category {
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 500; 
  margin-bottom: 0.5rem; letter-spacing: -0.01em; color: var(--text-primary);
}
.score-description {
  color: var(--text-secondary); font-size: 1.05rem; /* Better layout for reading */
  max-width: 540px; margin: 0 auto 1.75rem; line-height: 1.7;
}
.breakdown {
  text-align: left; border-top: 1px solid var(--border);
  padding-top: 1.5rem; margin-top: 1rem;
}
.breakdown h3 {
  font-family: var(--font-display); font-size: 1.25rem; /* Augmented readability */
  font-weight: 500; margin-bottom: 1rem; color: var(--text-primary);
}
.breakdown-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 0; font-size: 1rem; border-bottom: 1px solid var(--border);
}
.breakdown-item:last-child { border-bottom: none; }
.breakdown-name { color: var(--text-primary); flex: 1; font-size: 1rem; font-weight: 500; }
.breakdown-value {
  font-weight: 700; padding: 0.25rem 0.75rem;
  border-radius: 100px; font-size: 0.875rem; /* WCAG size */
}
.results-actions {
  display: flex; gap: 0.85rem; justify-content: center;
  margin-top: 2.25rem; flex-wrap: wrap;
}
.resources-box {
  background: var(--resources-bg); border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem; margin-top: 2rem; text-align: left;
}
.resources-box h4 {
  font-size: 1.15rem; font-weight: 700; color: var(--accent-dark); margin-bottom: 0.5rem;
}
.resources-box p { font-size: 1.05rem; color: var(--text-secondary); line-height: 1.65; }

/* ─── Breadcrumb (Hidden in immersive mode, styled for standard layout) ─── */
body.immersive-mode #test-breadcrumb { display: none !important; }
.breadcrumb {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 1rem; color: var(--text-muted); margin-bottom: 1.5rem;
}
.breadcrumb a {
  color: var(--text-muted); text-decoration: none; cursor: pointer;
  transition: color 0.25s; font-weight: 500;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .bc-sep { opacity: 0.4; }
.breadcrumb .bc-current { color: var(--accent); font-weight: 600; }

/* ─── SVG Score Ring ─── */
.score-ring-container {
  position: relative; width: 140px; height: 140px;
  margin: 0 auto 1.5rem;
  animation: scaleIn 0.6s var(--ease-spring);
}
.score-ring-bg {
  fill: none; stroke: var(--bg-tertiary); stroke-width: 8;
}
.score-ring-fill {
  fill: none; stroke-width: 8; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 1.4s var(--ease-premium);
}
.score-ring-text {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-ring-number {
  font-family: var(--font-display); font-size: 2.75rem;
  font-weight: 500; color: var(--text-primary); line-height: 1;
}
.score-ring-label {
  font-size: 0.875rem; color: var(--text-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px;
}

/* ─── History Elements... (Keeping them succinct but ensuring scale/WCAG) ─── */
.history-entry {
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  padding: 1.15rem 1.25rem; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 1rem;
  transition: all 0.3s var(--ease-premium);
  border: 1px solid var(--border); cursor: default;
}
.history-entry:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.history-dot { width: 12px; height: 12px; border-radius: 50%; min-width: 12px; }
.history-info { flex: 1; }
.history-date { font-size: 0.9rem; font-weight: 500; color: var(--text-muted); margin-bottom: 0.15rem; }
.history-score-text { font-weight: 700; font-size: 1.05rem; color: var(--text-primary); }
.history-test-name { font-size: 0.9rem; color: var(--text-secondary); margin-top: 0.15rem; }
.history-badge {
  font-size: 0.875rem; font-weight: 700; padding: 0.35rem 0.7rem;
  border-radius: 100px; color: white; white-space: nowrap; box-shadow: var(--shadow-sm);
}
.history-actions { display: flex; gap: 0.35rem; margin-left: 0.5rem; }
.btn-icon {
  background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 10px;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; transition: all 0.2s var(--ease-premium);
}
.btn-icon:hover { background: var(--accent-glow); border-color: var(--accent-light); transform: scale(1.08); }
.clear-history { text-align: center; margin-top: 2rem; }
.clear-cache-btn {
  font-size: 0.85rem; color: var(--text-muted);
  border: 1px solid var(--border); min-height: 40px;
  padding: 0.5rem 1rem; border-radius: 100px;
  transition: all 0.3s var(--ease-premium);
}
.clear-cache-btn:hover {
  color: #A65D57; border-color: #A65D57;
  background: rgba(166,93,87,0.06);
}

/* ─── Answer Detail Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9999;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; animation: fadeUp 0.3s var(--ease-premium);
}
.modal-content {
  background: var(--bg-secondary); border-radius: var(--radius);
  max-width: 680px; width: 100%; max-height: 85vh; overflow-y: auto;
  padding: clamp(1.5rem, 4vw, 2.5rem); box-shadow: var(--shadow-lg);
  position: relative;
}
.modal-close {
  position: absolute; top: 1rem; right: 1rem; background: var(--bg-tertiary);
  border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: all 0.2s;
}
.modal-close:hover { background: #A65D5720; color: #A65D57; }
.answer-item {
  padding: 0.85rem 0; border-bottom: 1px solid var(--border);
}
.answer-item:last-child { border-bottom: none; }
.answer-q { font-weight: 600; color: var(--text-primary); margin-bottom: 0.3rem; font-size: 0.95rem; }
.answer-a { color: var(--accent-dark); font-weight: 500; font-size: 0.95rem; }
.answer-a.highlighted { background: var(--accent-glow); padding: 0.25rem 0.5rem; border-radius: 6px; }
.share-box {
  background: var(--bg-tertiary); border-radius: var(--radius-sm);
  padding: 1rem; margin-top: 1rem; font-family: monospace; font-size: 0.85rem;
  white-space: pre-wrap; word-break: break-word; max-height: 50vh; overflow-y: auto;
  color: var(--text-primary); line-height: 1.5; border: 1px solid var(--border);
}
@media (max-width: 500px) {
  .history-entry { flex-wrap: wrap; }
  .history-actions { width: 100%; justify-content: flex-end; margin-top: 0.5rem; margin-left: 0; }
}

/* ─── Breakdown & Diagnostics Utilities ─── */
.breakdown-bar-bg {
  flex: 0 0 80px; height: 8px; background: var(--bg-tertiary);
  border-radius: 100px; overflow: hidden; margin-left: 0.8rem;
}
.breakdown-bar-fill {
  height: 100%; border-radius: 100px;
  transition: width 0.7s var(--ease-out);
}

.dimension-result { margin-bottom: 1.35rem; text-align: left; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.dimension-result:last-child { border-bottom: none; }
.dimension-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.dimension-name { font-weight: 700; font-size: 1.05rem; color: var(--text-primary); } 
.dimension-score { font-family: var(--font-display); font-size: 1.25rem; font-weight: 500; }
.dimension-bar { height: 8px; background: var(--bg-tertiary); border-radius: 100px; overflow: hidden; margin-bottom: 0.6rem; }
.dimension-bar-fill { height: 100%; border-radius: 100px; transition: width 0.8s var(--ease-out); }
.dimension-desc { font-size: 1.05rem; color: var(--text-secondary); line-height: 1.6; }

/* MBTI Elements */
.type-display { font-family: var(--font-display); font-size: 3.5rem; font-weight: 500; letter-spacing: 0.1em; margin-bottom: 0.25rem; }
.type-name { font-size: 1.2rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 1rem; font-style: italic; }
.dichotomy-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; font-size: 1rem; }
.dichotomy-label, .dichotomy-label-right { flex: 0 0 80px; font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.dichotomy-label { text-align: right; }
.dichotomy-label-right { text-align: left; }
.dichotomy-bar { flex: 1; height: 10px; background: var(--bg-tertiary); border-radius: 100px; position: relative; overflow: hidden; }
.dichotomy-bar-fill { position: absolute; top: 0; height: 100%; border-radius: 100px; transition: width 0.8s var(--ease-out); }

/* ─── Touch feedback & Responsive Adjustments ─── */
@media (max-width: 480px) {
  .test-card h3 { font-size: 1rem; line-height: 1.3; }
  .test-card p { font-size: 0.85rem; }
  .question-title { font-size: clamp(1.2rem, 5vw, 1.5rem); margin-bottom: 1.75rem; }
  .option { min-height: 58px; font-size: 1rem; padding: 1rem 1.1rem; } /* Tap target optimized */
  .results-actions { flex-direction: column; }
  .results-actions .btn { width: 100%; }
  .imm-title { font-size: 1.1rem; }
  .btn-close-test { width: 36px; height: 36px; font-size: 1rem; }
}
@media (hover: none) {
  .btn:active, .tab:active, .lang-btn:active, .option:active {
    transform: scale(0.97); transition: transform 0.1s;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.15s !important;
  }
}

/* ─── RTL Support ─── */
[dir="rtl"] .option:hover { transform: translateX(-4px); }
/* removed rtl selected translateX */
[dir="rtl"] .question-content { animation: slideInRtl 0.4s var(--ease-out); }
@keyframes slideInRtl {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}
[dir="rtl"] .question-nav { flex-direction: row-reverse; }
[dir="rtl"] .option .key-badge { right: auto; left: 0.75rem; }
[dir="rtl"] @keyframes optionFadeIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─── Toast animations ─── */
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ─── Header responsive < 420px ─── */
@media (max-width: 420px) {
  /* header-controls responsive handled above */
}

/* ══════════════════════════════════════════════════════════════
   Welcome Wizard Modal
   ══════════════════════════════════════════════════════════════ */
.wizard-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; animation: fadeUp 0.4s var(--ease-premium);
}
.wizard-content {
  background: var(--bg-secondary); border-radius: 16px;
  max-width: 520px; width: 100%; max-height: 85vh; overflow-y: auto;
  padding: clamp(1.5rem, 4vw, 2.5rem); box-shadow: var(--shadow-lg);
  position: relative; text-align: center;
}
.wizard-content h2 {
  font-family: var(--font-display); font-size: clamp(1.5rem, 4vw, 1.8rem);
  color: var(--accent); margin-bottom: 1rem;
}
.wizard-content p {
  color: var(--text-secondary); margin-bottom: 1rem; line-height: 1.6;
}
.wizard-steps {
  display: flex; flex-direction: column; gap: 0.75rem; margin: 1.5rem 0;
  text-align: left;
}
.wizard-step {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; background: var(--bg-tertiary);
  border-radius: 10px; transition: transform 0.2s;
}
.wizard-step:hover { transform: translateX(4px); }
.wizard-step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; flex-shrink: 0;
}
.wizard-step-text { font-size: 0.95rem; color: var(--text-primary); }
.wizard-buttons {
  display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.5rem;
}
.wizard-close {
  position: absolute; top: 1rem; right: 1rem; background: var(--bg-tertiary);
  border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: all 0.2s;
}
.wizard-close:hover { background: var(--accent); color: #fff; }

/* ═══════════════════════════════════════════════════════════════
   页面过渡与加载动画
═══════════════════════════════════════════════════════════════ */

/* 页面离开动画 */
.screen-exit {
  animation: screenExit 0.5s ease forwards;
}
@keyframes screenExit {
  to { opacity: 0; transform: translateX(-20px); }
}

/* 页面进入动画 */
.screen-enter {
  animation: screenEnter 0.6s ease forwards;
}
@keyframes screenEnter {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

}
.test-loader-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.test-loader-text {
  font-size: 1.1rem;
  color: var(--text-secondary);
  min-height: 24px;
}
.test-loader-progress {
  width: 200px;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
}
.test-loader-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* 题目进入动画 */
.question-exit {
  animation: questionExit 0.25s ease forwards;
}
@keyframes questionExit {
  to { opacity: 0; transform: translateX(-30px); }
}
.question-enter {
  animation: questionEnter 0.35s ease;
}
@keyframes questionEnter {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* 选项选中动画 */
.option-selected {
  animation: optionPop 0.3s ease;
}
@keyframes optionPop {
  50% { transform: scale(0.96); }
}

/* 进度条平滑动画 */
.progress-fill {
  transition: width 0.4s ease;
}

/* 页面懒加载过渡效果 (增强版) */
.screen-enter {
  animation: screenFadeIn 0.8s ease forwards;
  opacity: 0;
}
@keyframes screenFadeIn {
  0% { opacity: 0; transform: translateX(15px); filter: blur(2px); }
  60% { opacity: 0.8; filter: blur(0); }
  100% { opacity: 1; transform: translateX(0); filter: blur(0); }
}

/* 旧页面退出时加遮罩 */
.screen-exit {
  animation: screenExitWithDim 0.6s ease forwards;
  position: relative;
}
.screen-exit::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #fafafa;
  opacity: 0;
  animation: dimFade 0.6s ease forwards;
}
@keyframes screenExitWithDim {
  to { opacity: 0.6; transform: translateX(-20px); }
}
@keyframes dimFade {
  to { opacity: 0.3; }
}

/* 测试加载页动画 - 从上到下滑入 */
.test-loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, 
    hsl(var(--hue), 60%, 96%) 0%, 
    hsl(var(--hue), 55%, 92%) 50%,
    hsl(calc(var(--hue) + 15), 45%, 90%) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  gap: 32px;
  /* 从上方滑入 */
  transform: translateY(-100%);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 深色模式渐变 */
[data-theme="dark"] .test-loader-overlay {
  background: linear-gradient(135deg, 
    hsl(220, 40%, 12%) 0%, 
    hsl(240, 35%, 15%) 50%,
    hsl(260, 40%, 18%) 100%);
}

.test-loader-overlay.show {
  transform: translateY(0);
}

/* 浮动 Logo */
.test-loader-logo {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light, #A78BFA) 100%);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: white;
  box-shadow: 0 20px 40px -10px hsla(var(--hue), 70%, 50%, 0.4);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-15px) rotate(3deg); }
}

/* 步骤列表 */
.test-loader-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 240px;
}

.test-loader-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.test-loader-step.active {
  color: var(--text-primary);
  font-weight: 500;
}

.test-loader-step.completed {
  color: var(--primary);
}

.test-loader-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-subtle);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.test-loader-step.active .test-loader-step-dot {
  background: var(--primary);
  box-shadow: 0 0 0 4px hsla(var(--hue), 70%, 50%, 0.2);
  transform: scale(1.2);
}

.test-loader-step.completed .test-loader-step-dot {
  background: #10B981;
}

/* 进度条容器 */
.test-loader-progress-wrap {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.test-loader-progress {
  width: 100%;
  height: 8px;
  background: hsla(var(--hue), 20%, 50%, 0.15);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.test-loader-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, 
    var(--primary) 0%, 
    var(--primary-light, #A78BFA) 50%,
    #EC4899 100%);
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.test-loader-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4));
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-40px); }
  100% { transform: translateX(40px); }
}

/* 百分比文字 */
.test-loader-percent {
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* 旧样式兼容 */
.test-loader-text { display: none; }
.test-loader-spinner { display: none; }


/* ── 题目入场动画（20260505） ── */
@keyframes qSlideIn {
  from { opacity: 0; transform: translateX(28px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes optIn {
  from { opacity: 0; transform: scale(0.88) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes optOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.93); }
}
@keyframes optBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.95); }
  70%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.q-out       { animation: optOut 0.18s ease forwards !important; pointer-events: none; }
.q-in        { animation: qSlideIn 0.38s var(--ease-out) forwards; }
.option.q-animate-in {
  opacity: 0;
  animation: optIn 0.3s var(--ease-out) forwards;
}
.option.q-delay-1 { animation-delay: 55ms; }
.option.q-delay-2 { animation-delay: 110ms; }
.option.q-delay-3 { animation-delay: 165ms; }
.option.q-delay-4 { animation-delay: 220ms; }
.option.q-delay-5 { animation-delay: 275ms; }
.option.q-delay-6 { animation-delay: 330ms; }
.option-select-bounce { animation: optBounce 0.35s ease forwards; }


/* ── 最后题提示气泡（20260505） ── */
@keyframes lastQSlideUp {
  0%   { opacity: 0; transform: translateY(24px) scale(0.92); }
  60%  { opacity: 1; transform: translateY(-4px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes lastQFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-7px); }
}
@keyframes lastQArrowBounce {
  0%, 100% { transform: translateX(0); }
  50%       { transform: translateX(6px); }
}
@keyframes lastQPulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 hsla(var(--accent-hue, 260), 70%, 60%, 0.35); }
  50%       { box-shadow: 0 0 0 8px hsla(var(--accent-hue, 260), 70%, 60%, 0); }
}

#last-q-tip .tip-icon { font-size: 1.4rem; vertical-align: middle; margin-right: 6px; }
#last-q-tip .tip-arrow {
  display: inline-block;
  animation: lastQArrowBounce 0.9s ease-in-out 0.8s 3;
  margin-left: 4px;
  vertical-align: middle;
}
#last-q-tip .tip-btn {
  display: inline-block;
  background: linear-gradient(135deg, #9B59B6, #8E44AD);
  color: white;
  font-weight: 600;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.9rem;
  margin-top: 10px;
  pointer-events: all;
  animation: lastQPulseGlow 1.8s ease-in-out 0.6s 2;
  cursor: pointer;
}
.dark #last-q-tip {
  background: #2D2535;
  color: #EEE4ED;
  border-color: rgba(167,139,250,0.3);
}
.dark #last-q-tip::before { background: #2D2535; border-color: rgba(167,139,250,0.3); }
.dark #last-q-tip .tip-btn { background: linear-gradient(135deg, #7C3AED, #6D28D9); }

/* 按钮上叠加光晕 */
#btn-next.pulse-hint {
  animation: pulseHint 1.2s ease-in-out 2, lastQPulseGlow 1.8s ease-in-out 0.6s 2;
}


/* ── 最后题提示气泡（JS动态追踪btn-next） ── */
#last-q-tip {
  position: fixed;           /* 相对于视口，JS动态计算位置 */
  background: white;
  color: #2D1F33;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
  z-index: 998;
  text-align: center;
  max-width: 260px;
  width: max-content;
  min-width: 180px;
  animation: lastQSlideUp 0.55s var(--ease-spring) forwards,
             lastQFloat 2.8s ease-in-out 0.6s 3;
  pointer-events: none;
  border: 1.5px solid rgba(155,89,182,0.18);
  /* JS会设置 top 和 left */
}
#last-q-tip::before {
  content: '';
  position: absolute;
  bottom: -7px;
  left: var(--arrow-left, 50%);  /* JS动态计算，默认居中 */
  transform: translateX(-50%) rotate(45deg);
  width: 14px; height: 14px;
  background: white;
  border-right: 1.5px solid rgba(155,89,182,0.18);
  border-bottom: 1.5px solid rgba(155,89,182,0.18);
  z-index: -1;
}

/* 移动端 */
@media (max-width: 480px) {
  #last-q-tip {
    padding: 10px 14px;
    font-size: 0.85rem;
    max-width: 220px;
    min-width: 160px;
    border-radius: 12px;
  }
  #last-q-tip .tip-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    margin-top: 8px;
  }
  #last-q-tip::before {
    width: 12px; height: 12px;
    bottom: -6px;
  }
}
@media (max-width: 360px) {
  #last-q-tip {
    max-width: 200px;
    font-size: 0.82rem;
  }
}

/* 禁止移动端缩放 - iOS兼容 */
html {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    touch-action: manipulation;
    -webkit-overflow-scrolling: touch;
}

/* 允许输入框选择文字 */
input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* 禁止双击缩放 */
* {
    touch-action: manipulation;
}

/* iOS Safari 特定修复 */
@supports (-webkit-touch-callout: none) {
    html {
        -webkit-text-size-adjust: 100%;
    }
}
