/* ============================================
   Bingojob AI 语音测评 - 样式系统
   VI Color System:
   - Primary Blue:   #2B2BFF
   - Primary Purple: #9B4DFF
   - Accent Green:   #00E64D
   - Black:          #000000
   - Background:     #F8F8FA
   ============================================ */

/* === CSS Variables === */
:root {
    --blue: #2B2BFF;
    --blue-light: #5B5BFF;
    --blue-bg: rgba(43, 43, 255, 0.08);
    --purple: #9B4DFF;
    --purple-light: #B77FFF;
    --purple-bg: rgba(155, 77, 255, 0.08);
    --green: #00E64D;
    --green-light: #33FF77;
    --green-bg: rgba(0, 230, 77, 0.1);
    --red: #FF4757;
    --red-light: #FF6B7A;
    --red-bg: rgba(255, 71, 87, 0.1);
    --orange: #FFA502;
    
    --bg: #F8F8FA;
    --bg-card: #FFFFFF;
    --text-primary: #1A1A2E;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    
    --gradient-primary: linear-gradient(135deg, #2B2BFF 0%, #9B4DFF 100%);
    --gradient-button: linear-gradient(135deg, #2B2BFF 0%, #7B3FFF 50%, #9B4DFF 100%);
    --gradient-green: linear-gradient(135deg, #00E64D 0%, #00CC44 100%);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-button: 0 4px 20px rgba(43, 43, 255, 0.35);
    --shadow-purple: 0 4px 20px rgba(155, 77, 255, 0.35);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;
    
    --safe-bottom: env(safe-area-inset-bottom, 16px);
    --safe-top: env(safe-area-inset-top, 0px);
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    -webkit-font-smoothing: antialiased;
}

#app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

/* === Page System === */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(30px);
    pointer-events: none;
    transition: all 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

.page.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.page.exit-left {
    opacity: 0;
    transform: translateX(-30px);
}

.page-content {
    flex: 1;
    padding: 20px 24px;
    padding-top: calc(var(--safe-top) + 20px);
}

.page-content.center-all {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.page-footer {
    padding: 16px 24px;
    padding-bottom: calc(var(--safe-bottom) + 16px);
    background: linear-gradient(to top, var(--bg) 80%, transparent);
}

/* === Buttons === */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--gradient-button);
    color: #fff;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-button);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s ease;
}

.btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 10px rgba(43, 43, 255, 0.3);
}

.btn-primary:active::before {
    left: 100%;
}

.btn-primary.disabled,
.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 24px;
    border: 2px solid var(--blue);
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--blue);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:active {
    background: var(--blue-bg);
    transform: scale(0.97);
}

.btn-ghost {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
}

.btn-full {
    width: 100%;
}

/* === Welcome Page (Page 1) === */
.logo-area {
    text-align: center;
    margin-bottom: 8px;
}

.brand-logo {
    height: 42px;
    object-fit: contain;
}

.welcome-hero {
    text-align: center;
    padding: 16px 0;
}

.ai-avatar {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
}

.avatar-ring {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.avatar-ring i {
    font-size: 36px;
    color: #fff;
}

.avatar-pulse {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 96px;
    height: 96px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    opacity: 0.25;
    animation: pulse 2s ease-in-out infinite;
    z-index: 1;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.25; }
    50% { transform: scale(1.15); opacity: 0.1; }
}

.welcome-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.3;
}

.welcome-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.welcome-subtitle strong {
    color: var(--blue);
    font-weight: 700;
}

.welcome-reassure {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--purple-bg);
    border-radius: var(--radius-xl);
    color: var(--purple);
    font-size: 0.85rem;
    font-weight: 600;
}

.welcome-reassure i {
    font-size: 0.95rem;
}

/* Feature chips */
.features-strip {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.feature-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

.feature-chip i {
    color: var(--blue);
    font-size: 0.85rem;
}

.footer-hint {
    text-align: center;
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

/* === Permission Modal === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border-radius: var(--radius-xl) var(--radius-xl) var(--radius-lg) var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    animation: slideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    margin-bottom: var(--safe-bottom);
}

@keyframes slideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
}

.modal-icon.warning {
    background: var(--red-bg);
    color: var(--red);
}

.modal-card h3 {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.modal-card > p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.tutorial-steps {
    text-align: left;
    margin-bottom: 24px;
}

.tutorial-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.tutorial-step:last-child {
    border-bottom: none;
}

.step-num {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.step-text strong {
    color: var(--blue);
}

/* === Pre-flight Check (Page 2) === */
.preflight-header {
    text-align: center;
    margin-bottom: 32px;
}

.check-icon-wrap {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: var(--blue-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
    color: var(--blue);
}

.preflight-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
}

.page-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 6px;
}

.sound-wave-container {
    width: 100%;
    max-width: 300px;
    margin: 0 auto 32px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

#wave-canvas {
    width: 100%;
    height: 100px;
    display: block;
}

.read-prompt {
    text-align: center;
    margin-bottom: 24px;
}

.prompt-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.number-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.num {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 800;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
}

.num.active {
    transform: scale(1.15);
    box-shadow: var(--shadow-button);
}

.num-sep {
    color: var(--text-tertiary);
    font-size: 1.2rem;
}

.env-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.env-status.hidden {
    display: none;
}

.env-status.success {
    background: var(--green-bg);
    color: #059669;
}

.env-status.warning {
    background: rgba(255, 165, 2, 0.1);
    color: #D97706;
}

.env-status.error {
    background: var(--red-bg);
    color: var(--red);
}

/* === Question / Recording Pages === */
.progress-bar-wrap {
    margin-bottom: 24px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.progress-step {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-xl);
    background: var(--purple-bg);
    color: var(--purple);
}

.progress-track {
    height: 6px;
    border-radius: 3px;
    background: var(--border-light);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--gradient-primary);
    transition: width 0.5s ease;
}

/* Question Card */
.question-card {
    margin-bottom: 32px;
}

.question-instruction {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 600;
}

.question-text-box {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.quote-icon {
    position: absolute;
    font-size: 1.2rem;
    color: var(--purple-light);
    opacity: 0.5;
}

.quote-icon:first-of-type {
    top: 12px;
    left: 14px;
}

.quote-icon.right {
    bottom: 12px;
    right: 14px;
}

.question-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.7;
    text-align: center;
}

/* === Recording Button === */
.recorder-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
}

.recorder-area.compact {
    padding: 8px 0;
}

.rec-button {
    position: relative;
    width: 100px;
    height: 100px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.rec-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    border: 3px solid var(--border);
    transition: all 0.3s ease;
}

.rec-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 72px;
    border-radius: var(--radius-full);
    background: var(--gradient-button);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-button);
    transition: all 0.3s ease;
    z-index: 2;
}

.rec-inner i {
    font-size: 28px;
    color: #fff;
}

.rec-inner.active {
    background: var(--red);
    box-shadow: 0 4px 20px rgba(255, 71, 87, 0.4);
}

.rec-wave-ring {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    z-index: 1;
}

.rec-wave-ring.active {
    border-color: rgba(255, 71, 87, 0.3);
    animation: recPulse 1.5s ease-in-out infinite;
}

@keyframes recPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.5; }
}

.rec-button.recording .rec-ring {
    border-color: var(--red);
    animation: recPulse 1.5s ease-in-out infinite;
}

.rec-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.rec-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.rec-timer.hidden {
    display: none;
}

.timer-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--text-tertiary);
}

.timer-dot.active {
    background: var(--red);
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.timer-max {
    color: var(--text-tertiary);
    font-weight: 400;
    font-size: 0.85rem;
}

/* === Scenario Page (Page 4) === */
.scenario-player {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    margin-bottom: 24px;
}

.ai-speaker {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.ai-speaker-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
}

.ai-speaker-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.audio-wave-mini {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
}

.audio-wave-mini span {
    display: block;
    width: 3px;
    background: var(--blue);
    border-radius: 2px;
    animation: miniWave 0.8s ease-in-out infinite;
}

.audio-wave-mini span:nth-child(1) { height: 4px; animation-delay: 0s; }
.audio-wave-mini span:nth-child(2) { height: 8px; animation-delay: 0.15s; }
.audio-wave-mini span:nth-child(3) { height: 12px; animation-delay: 0.3s; }
.audio-wave-mini span:nth-child(4) { height: 6px; animation-delay: 0.45s; }
.audio-wave-mini span:nth-child(5) { height: 10px; animation-delay: 0.6s; }

.audio-wave-mini.stopped span {
    animation: none;
    height: 3px;
}

@keyframes miniWave {
    0%, 100% { height: 3px; }
    50% { height: 14px; }
}

.scenario-text-box {
    background: var(--purple-bg);
    border-radius: var(--radius-md);
    padding: 16px;
}

.scenario-badge {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--purple);
    margin-bottom: 8px;
}

#scenario-text {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
    font-weight: 600;
}

/* Phase cards */
.scenario-state-area {
    margin-top: 8px;
}

.phase-card {
    text-align: center;
    padding: 16px;
}

.phase-card.hidden {
    display: none;
}

.phase-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 22px;
}

.phase-icon.thinking {
    background: rgba(255, 165, 2, 0.12);
    color: var(--orange);
    animation: thinking 2s ease-in-out infinite;
}

@keyframes thinking {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.phase-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Countdown circle */
.countdown-circle {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto;
}

.countdown-circle svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.countdown-bg {
    fill: none;
    stroke: var(--border-light);
    stroke-width: 4;
}

.countdown-ring {
    fill: none;
    stroke: var(--orange);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.countdown-num {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* Switch warning */
.switch-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    background: var(--red);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    z-index: 999;
    animation: slideDown 0.3s ease;
}

.switch-warning.hidden {
    display: none;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* === Complete Page (Page 5) === */
.complete-animation {
    position: relative;
    margin-bottom: 32px;
}

.success-check {
    width: 100px;
    height: 100px;
    margin: 0 auto;
}

.success-check svg {
    width: 100%;
    height: 100%;
}

.check-circle {
    fill: none;
    stroke: var(--green);
    stroke-width: 4;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    animation: drawCircle 0.6s ease forwards 0.2s;
}

.check-mark {
    fill: none;
    stroke: var(--green);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    animation: drawCheck 0.4s ease forwards 0.7s;
}

@keyframes drawCircle {
    to { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
    to { stroke-dashoffset: 0; }
}

.complete-title {
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 8px;
}

.complete-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
}

.complete-info-card {
    width: 100%;
    max-width: 340px;
    background: var(--blue-bg);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin: 0 auto;
}

.info-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.info-row i {
    font-size: 1.2rem;
    color: var(--blue);
    margin-top: 2px;
}

.info-row span {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Upload Status */
.upload-status {
    margin-top: 24px;
    text-align: center;
}

.upload-status.hidden {
    display: none;
}

.upload-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: var(--radius-full);
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.upload-status p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 12px;
}

.upload-progress-bar {
    width: 200px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* === Confetti Animation === */
.confetti-container {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 120px;
    overflow: visible;
    pointer-events: none;
}

.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    animation: confettiFall 2s ease-in-out forwards;
}

@keyframes confettiFall {
    0% { 
        transform: translateY(0) rotate(0deg) scale(1); 
        opacity: 1; 
    }
    100% { 
        transform: translateY(120px) rotate(720deg) scale(0); 
        opacity: 0; 
    }
}

/* === Loading Overlay === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 248, 250, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--blue);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

/* === Utility Classes === */
.hidden {
    display: none !important;
}

/* === Responsive fine-tuning === */
@media (max-height: 680px) {
    .welcome-hero { padding: 8px 0; }
    .ai-avatar { width: 64px; height: 64px; margin-bottom: 12px; }
    .avatar-ring { width: 64px; height: 64px; }
    .avatar-ring i { font-size: 28px; }
    .avatar-pulse { width: 80px; height: 80px; top: -8px; left: -8px; }
    .welcome-title { font-size: 1.3rem; }
    .welcome-subtitle { font-size: 0.95rem; }
    .features-strip { margin-top: 12px; }
    .rec-button { width: 88px; height: 88px; }
    .rec-inner { width: 64px; height: 64px; }
    .rec-wave-ring { width: 108px; height: 108px; top: -10px; left: -10px; }
}

@media (max-height: 580px) {
    .ai-avatar { display: none; }
    .brand-logo { height: 32px; }
    .page-content { padding: 12px 20px; }
    .welcome-reassure { padding: 8px 14px; font-size: 0.8rem; }
}

/* =============================================
   语言切换器 (Language Switcher)
   ============================================= */
.lang-switcher {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 900;
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 3px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.lang-switcher.hide {
    transform: translateY(-60px);
    opacity: 0;
    pointer-events: none;
}

.lang-btn {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-xl);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    line-height: 1.3;
}

.lang-btn:active {
    transform: scale(0.95);
}

.lang-btn.active {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-button);
}

/* 高棉语按钮稍微调大字体确保可读 */
.lang-btn[data-lang="km"] {
    font-family: 'Noto Sans Khmer', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0;
}

/* =============================================
   高棉语 (Khmer) 字体适配
   ============================================= */
[data-lang="km"] body,
[data-lang="km"] .welcome-title,
[data-lang="km"] .welcome-subtitle,
[data-lang="km"] .welcome-reassure span,
[data-lang="km"] .feature-chip span,
[data-lang="km"] .btn-primary span,
[data-lang="km"] .btn-secondary span,
[data-lang="km"] .btn-ghost,
[data-lang="km"] .modal-card h3,
[data-lang="km"] .modal-card > p,
[data-lang="km"] .step-text,
[data-lang="km"] .preflight-header h2,
[data-lang="km"] .page-desc,
[data-lang="km"] .prompt-label,
[data-lang="km"] .progress-step,
[data-lang="km"] .progress-tag span,
[data-lang="km"] .question-instruction,
[data-lang="km"] .scenario-badge,
[data-lang="km"] .ai-label,
[data-lang="km"] .phase-label,
[data-lang="km"] .rec-hint,
[data-lang="km"] .env-status span,
[data-lang="km"] .complete-title,
[data-lang="km"] .complete-desc,
[data-lang="km"] .info-row span,
[data-lang="km"] .upload-status p,
[data-lang="km"] .switch-warning span,
[data-lang="km"] .footer-hint {
    font-family: 'Noto Sans Khmer', 'Nunito', sans-serif;
}

/* 高棉语文字需要稍大行高 */
[data-lang="km"] .welcome-title {
    font-size: 1.35rem;
    line-height: 1.6;
}

[data-lang="km"] .welcome-subtitle {
    font-size: 0.95rem;
    line-height: 1.7;
}

[data-lang="km"] .question-text {
    line-height: 1.8;
}

[data-lang="km"] .scenario-text-box p {
    line-height: 1.8;
    font-size: 0.92rem;
}

[data-lang="km"] .complete-title {
    font-size: 1.3rem;
    line-height: 1.6;
}

[data-lang="km"] .modal-card h3 {
    line-height: 1.5;
}

[data-lang="km"] .step-text {
    line-height: 1.6;
}

[data-lang="km"] .btn-primary,
[data-lang="km"] .btn-secondary {
    font-size: 0.95rem;
    padding: 14px 20px;
}

/* 英语微调 */
[data-lang="en"] .welcome-title {
    font-size: 1.4rem;
}

[data-lang="en"] .scenario-text-box p {
    font-size: 0.92rem;
}

/* =============================================
   副标题 sub2 样式
   ============================================= */
.welcome-subtitle.sub2 {
    font-size: 0.92rem;
    margin-top: 4px;
}
