/* Glassmorphism containers and inputs */
.apple-glass {
    background: rgba(255, 255, 255, 0.015);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Light theme overrides for pure white screen background & high-contrast text */
html:not(.dark) .typing-speed-test-page {
    color: #0f172a;
    background-color: #ffffff !important;
}

html:not(.dark) body {
    background-color: #ffffff !important;
}

html:not(.dark) .typing-speed-test-page .apple-glass {
    background: #ffffff !important;
    border-color: rgba(226, 232, 240, 0.9) !important;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.06), 0 4px 6px -2px rgba(0, 0, 0, 0.03) !important;
}

html:not(.dark) .typing-speed-test-page .text-zinc-400,
html:not(.dark) .typing-speed-test-page .text-zinc-500,
html:not(.dark) .typing-speed-test-page .text-zinc-300,
html:not(.dark) .typing-speed-test-page .text-zinc-200 {
    color: #475569 !important;
}

html:not(.dark) .diff-btn.active,
html:not(.dark) .mode-type-btn.active,
html:not(.dark) .custom-type-btn.active,
html:not(.dark) .custom-val-btn.active,
html:not(.dark) .diff-btn.active *,
html:not(.dark) .mode-type-btn.active *,
html:not(.dark) .custom-type-btn.active *,
html:not(.dark) .custom-val-btn.active * {
    color: #ffffff !important;
}

html:not(.dark) .typing-speed-test-page .bg-zinc-950\/60,
html:not(.dark) .typing-speed-test-page .bg-zinc-950\/40,
html:not(.dark) .typing-speed-test-page .bg-zinc-950 {
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

html:not(.dark) .typing-speed-test-page .border-white\/5,
html:not(.dark) .typing-speed-test-page .border-white\/10 {
    border-color: #e2e8f0 !important;
}

/* Premium Apple-Grade Test Cards */
.premium-test-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 1.75rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.06);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

html.dark .premium-test-card {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.premium-test-card:hover {
    transform: translateY(-4px);
    border-color: rgba(14, 165, 233, 0.4) !important;
    box-shadow: 0 20px 45px -10px rgba(14, 165, 233, 0.2) !important;
}

/* Custom Gradient Action Buttons */
.btn-launch-sky {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #ffffff !important;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
    transition: all 0.2s ease;
}

.btn-launch-sky:hover {
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.5);
}

.btn-launch-indigo {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff !important;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    transition: all 0.2s ease;
}

.btn-launch-indigo:hover {
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-launch-emerald {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff !important;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
    transition: all 0.2s ease;
}

.btn-launch-emerald:hover {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-launch-amber {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff !important;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
    transition: all 0.2s ease;
}

.btn-launch-amber:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

/* Full-Screen Immersive Typing Studio Modal Overlay */
#fullscreen-typing-studio {
    background-color: #090d16;
    color: #f8fafc;
}

/* Light Theme Support for Full-Screen Studio */
html:not(.dark) #fullscreen-typing-studio {
    background-color: #f8fafc !important;
    color: #0f172a !important;
}

html:not(.dark) #fullscreen-typing-studio header {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
}

html:not(.dark) #fullscreen-typing-studio #studio-mode-title {
    color: #0f172a !important;
}

html:not(.dark) #fullscreen-typing-studio .apple-glass {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05) !important;
}

/* Off-screen Hidden Native Input (Fixes White Box Autofill Artifact) */
.hidden-typing-input {
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

/* 3-LINE COMPACT TYPING CANVAS (Height = 3 lines = 9.6rem) */
.notebook-paper {
    background-color: #0d1117;
    background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 100% 3.2rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    border-radius: 1.25rem;
    position: relative;
    line-height: 3.2rem !important;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

html:not(.dark) #fullscreen-typing-studio .notebook-paper {
    background-color: #ffffff !important;
    background-image: linear-gradient(#e2e8f0 1px, transparent 1px) !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06) !important;
}

/* Restrict words wrapper to EXACTLY 3 lines (3 * 3.2rem = 9.6rem) */
.notebook-words-wrapper {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 1.3rem;
    letter-spacing: 0.08em;
    user-select: none;
    line-height: 3.2rem !important;
    height: 9.6rem !important;
    max-height: 9.6rem !important;
    overflow-y: hidden !important;
    scroll-behavior: smooth !important;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (min-width: 640px) {
    .notebook-words-wrapper {
        font-size: 1.6rem;
        letter-spacing: 0.12em;
    }
}

/* Code Mode Styling */
.is-code-mode .notebook-words-wrapper {
    font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace !important;
    font-size: 1.2rem !important;
    letter-spacing: 0.05em !important;
}

/* Character states on notebook paper */
.typing-char {
    position: relative;
    transition: color 0.08s ease, background-color 0.08s ease;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 500;
}

html:not(.dark) #fullscreen-typing-studio .typing-char {
    color: #64748b !important;
}

.typing-char.correct {
    color: #10b981 !important; /* Emerald 500 */
    font-weight: 700;
}

html:not(.dark) #fullscreen-typing-studio .typing-char.correct {
    color: #059669 !important;
}

.typing-char.incorrect {
    color: #f43f5e !important; /* Rose 500 */
    background: rgba(244, 63, 94, 0.25) !important;
    border-radius: 3px;
    font-weight: 700;
    text-decoration: underline;
}

html:not(.dark) #fullscreen-typing-studio .typing-char.incorrect {
    color: #e11d48 !important;
    background: #ffe4e6 !important;
}

/* Active Character Blue Underline */
.typing-char.active-char {
    color: #38bdf8 !important;
    font-weight: 800;
    border-bottom: 3px solid #38bdf8;
    animation: activeGlow 1s infinite alternate;
}

html:not(.dark) #fullscreen-typing-studio .typing-char.active-char {
    color: #0284c7 !important;
    border-bottom-color: #0284c7;
}

@keyframes activeGlow {
    0% { border-bottom-color: #0284c7; }
    100% { border-bottom-color: #38bdf8; }
}

/* Floating "Start Typing!" Tooltip Pointer */
.start-typing-tooltip {
    position: absolute;
    top: -2.8rem;
    left: -0.5rem;
    background: #1e293b;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 30;
    animation: floatTooltip 1.8s infinite ease-in-out;
    pointer-events: none;
    white-space: nowrap;
}

.start-typing-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 12px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #1e293b;
}

@keyframes floatTooltip {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Full Mechanical Keyboard Layout (Desktop 3D Keycaps) */
.mech-keyboard {
    user-select: none;
    -webkit-user-select: none;
}

.v-key {
    height: 2.85rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 0.65rem;
    transition: all 0.12s ease;
    cursor: pointer;
    background: #1e293b;
    border: 1px solid #334155;
    color: #f8fafc;
    box-shadow: 0 4px 0 #0f172a, 0 5px 10px rgba(0, 0, 0, 0.4);
    position: relative;
}

html:not(.dark) #fullscreen-typing-studio .v-key {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #1e293b !important;
    box-shadow: 0 4px 0 #cbd5e1, 0 5px 10px rgba(0, 0, 0, 0.05) !important;
}

html.dark #fullscreen-typing-studio .v-key {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
    box-shadow: 0 4px 0 #0f172a, 0 5px 10px rgba(0, 0, 0, 0.5) !important;
}

.v-key:active, .v-key.active-key {
    background: #0ea5e9 !important;
    color: #ffffff !important;
    border-color: #0284c7 !important;
    transform: translateY(3px);
    box-shadow: 0 1px 0 #0284c7, 0 0 15px rgba(14, 165, 233, 0.6) !important;
}

/* Finger Color Tints for Keycaps */
.v-key.finger-pinky { border-top: 3px solid #ec4899; }
.v-key.finger-ring { border-top: 3px solid #a855f7; }
.v-key.finger-middle { border-top: 3px solid #3b82f6; }
.v-key.finger-index { border-top: 3px solid #10b981; }
.v-key.finger-thumb { border-top: 3px solid #f59e0b; }

/* Interactive Target Key Glowing Pulse */
.v-key.target-key-glow {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%) !important;
    color: #ffffff !important;
    border-color: #38bdf8 !important;
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 0 22px rgba(14, 165, 233, 0.9), 0 0 8px #38bdf8 !important;
    z-index: 20;
    animation: keyPulseGlow 1s infinite alternate ease-in-out;
}

@keyframes keyPulseGlow {
    0% { transform: scale(1.05) translateY(-2px); box-shadow: 0 0 12px rgba(14, 165, 233, 0.6); }
    100% { transform: scale(1.1) translateY(-3px); box-shadow: 0 0 25px rgba(56, 189, 248, 0.95), 0 0 10px #38bdf8; }
}

/* Hide scrollbars on result modal */
.no-scrollbar::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}
.no-scrollbar {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}

/* Result Modal Theme Adaptability */
html:not(.dark) #typing-result-modal {
    background-color: rgba(15, 23, 42, 0.5) !important;
    backdrop-filter: blur(12px) !important;
}

html:not(.dark) #typing-result-modal .modal-card {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.15) !important;
}

html:not(.dark) #typing-result-modal #result-rank {
    color: #0f172a !important;
}

html:not(.dark) #typing-result-modal #result-badge {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
    border: 1px solid #bae6fd !important;
}

html:not(.dark) #typing-result-modal .result-hero-box {
    background-color: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.02) !important;
}

html:not(.dark) #typing-result-modal .hero-label {
    color: #64748b !important;
}

html:not(.dark) #typing-result-modal #result-wpm {
    color: #0284c7 !important;
}

html:not(.dark) #typing-result-modal #result-raw-wpm {
    color: #4f46e5 !important;
}

html:not(.dark) #typing-result-modal .metric-card {
    background-color: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
}

html:not(.dark) #typing-result-modal .metric-label {
    color: #64748b !important;
}

html:not(.dark) #typing-result-modal #btn-close-modal {
    background-color: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
}

html:not(.dark) #typing-result-modal #btn-close-modal:hover {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
}

/* Custom Setup Selector Pills & Buttons */
.diff-btn, .mode-type-btn, .custom-type-btn, .custom-val-btn {
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

html:not(.dark) .diff-btn,
html:not(.dark) .mode-type-btn,
html:not(.dark) .custom-type-btn,
html:not(.dark) .custom-val-btn {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

.diff-btn.active,
.mode-type-btn.active,
.custom-type-btn.active,
.custom-val-btn.active {
    background: #0ea5e9 !important;
    border-color: #0284c7 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35) !important;
}

/* Modal Animation */
@keyframes modalPopIn {
    0% { transform: scale(0.92); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.animate-modal-pop {
    animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Mobile Responsiveness Improvements */
@media (max-width: 640px) {
    #fullscreen-typing-studio header {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .notebook-paper {
        padding: 0.85rem !important;
        min-height: 200px !important;
    }

    .notebook-words-wrapper {
        font-size: 1.15rem !important;
        line-height: 2.8rem !important;
        height: 8.4rem !important;
        max-height: 8.4rem !important;
    }

    .start-typing-tooltip {
        display: none !important;
    }

    #typing-result-modal .modal-card {
        padding: 1.15rem !important;
    }

    /* Prevent text collision on card badges */
    .premium-test-card h3 {
        font-size: 1.35rem !important;
    }
}

/* ---------------------------------------------------------
   WEAK KEY ANALYSIS & HEATMAP STYLING
   --------------------------------------------------------- */
.weak-key-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    transition: all 0.2s ease;
}

.weak-key-chip-high {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.35);
    color: #f43f5e;
}

html:not(.dark) .weak-key-chip-high {
    background: #ffe4e6;
    border-color: #fda4af;
    color: #e11d48;
}

.weak-key-chip-med {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #f59e0b;
}

html:not(.dark) .weak-key-chip-med {
    background: #fef3c7;
    border-color: #fde68a;
    color: #d97706;
}

/* Weak Key Heatmap Keyboard Key States */
#weak-keys-heatmap-keyboard .v-key {
    cursor: default;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
    position: relative;
}

#weak-keys-heatmap-keyboard .v-key:hover {
    transform: translateY(-2px);
    z-index: 10;
}

/* Accurate Keys: Green / Emerald */
#weak-keys-heatmap-keyboard .v-key.heat-accurate {
    background: rgba(16, 185, 129, 0.2) !important;
    border-color: rgba(16, 185, 129, 0.5) !important;
    color: #34d399 !important;
    box-shadow: 0 4px 0 rgba(5, 150, 105, 0.4), 0 0 10px rgba(16, 185, 129, 0.15) !important;
}

html:not(.dark) #weak-keys-heatmap-keyboard .v-key.heat-accurate {
    background: #d1fae5 !important;
    border-color: #6ee7b7 !important;
    color: #065f46 !important;
    box-shadow: 0 4px 0 #a7f3d0 !important;
}

/* Low Error Keys: Amber / Yellow */
#weak-keys-heatmap-keyboard .v-key.heat-low {
    background: rgba(245, 158, 11, 0.2) !important;
    border-color: rgba(245, 158, 11, 0.5) !important;
    color: #fbbf24 !important;
    box-shadow: 0 4px 0 rgba(217, 119, 6, 0.4), 0 0 10px rgba(245, 158, 11, 0.15) !important;
}

html:not(.dark) #weak-keys-heatmap-keyboard .v-key.heat-low {
    background: #fef3c7 !important;
    border-color: #fde68a !important;
    color: #92400e !important;
    box-shadow: 0 4px 0 #fde68a !important;
}

/* Moderate Error Keys: Orange */
#weak-keys-heatmap-keyboard .v-key.heat-med {
    background: rgba(249, 115, 22, 0.25) !important;
    border-color: rgba(249, 115, 22, 0.6) !important;
    color: #fb923c !important;
    box-shadow: 0 4px 0 rgba(194, 65, 12, 0.5), 0 0 12px rgba(249, 115, 22, 0.2) !important;
}

html:not(.dark) #weak-keys-heatmap-keyboard .v-key.heat-med {
    background: #ffedd5 !important;
    border-color: #fdba74 !important;
    color: #9a3412 !important;
    box-shadow: 0 4px 0 #fdba74 !important;
}

/* Weak / Critical Error Keys: Rose / Red with Subtle Glow */
#weak-keys-heatmap-keyboard .v-key.heat-weak {
    background: rgba(244, 63, 94, 0.3) !important;
    border-color: rgba(244, 63, 94, 0.7) !important;
    color: #fda4af !important;
    box-shadow: 0 4px 0 rgba(225, 29, 72, 0.6), 0 0 16px rgba(244, 63, 94, 0.35) !important;
    font-weight: 900;
}

html:not(.dark) #weak-keys-heatmap-keyboard .v-key.heat-weak {
    background: #ffe4e6 !important;
    border-color: #f43f5e !important;
    color: #9f1239 !important;
    box-shadow: 0 4px 0 #fca5a5 !important;
    font-weight: 900;
}

/* Untyped / Neutral */
#weak-keys-heatmap-keyboard .v-key.heat-untyped {
    opacity: 0.65;
}

