/* --- FINAL CLEAN & MINIMALIST DESIGN --- */

/* 1. DESIGN SYSTEM & COLOR PALETTE */
:root {
    --font-sans: 'Inter', sans-serif;
    /* Light Theme */
    --background: 0 0% 100%;
    --foreground: 0 0% 3.9%;
    --card: 0 0% 100%;
    --secondary: 0 0% 96.1%;
    --muted-foreground: 0 0% 45.1%;
    --border: 0 0% 89.8%;
    --primary: 0 0% 9%;
    --primary-foreground: 0 0% 98%;
    --success: 142.1 76.2% 36.3%;
    --warning: 47.9 95.8% 53.1%;
    --destructive: 0 84.2% 60.2%;
    --radius: 0.75rem;
    --transition-fast: all 0.2s ease-out;
}
[data-theme="dark"] {
    --background: 220 13% 10%;
    --foreground: 0 0% 98%;
    --card: 220 13% 14%;
    --secondary: 220 13% 18%;
    --muted-foreground: 0 0% 63.9%;
    --border: 220 13% 25%;
    --primary: 0 0% 98%;
    --primary-foreground: 0 0% 9%;
    --success: 142.1 70.6% 35.3%;
    --warning: 47.9 90.8% 40.1%;
    --destructive: 0 62.8% 40.6%;
}

/* 2. GLOBAL STYLES */
* { box-sizing: border-box; }
html {
    font-size: 14px; /* Slightly increased base size for better mobile readability */
}
body {
    background-color: hsl(var(--background)); color: hsl(var(--foreground)); font-family: var(--font-sans); margin: 0; padding-top: 63px; line-height: 1.6;
}
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}
h1, h2, h3, h4 { color: hsl(var(--foreground)); font-weight: 600; }
p { color: hsl(var(--muted-foreground)); }
h1 { font-size: 2.25rem; text-align: center; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.1rem; }

/* 3. HEADER & TOP BAR */
.site-header {
    background-color: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
    padding: 0 1.5rem;
    height: 60px;
    position: fixed;
    top: 3px;
    left: 0;
    width: 100%;
    z-index: 1000;
    display: flex; /* Changed from grid to flex for simpler mobile header layout */
    justify-content: space-between; /* Distribute items */
    align-items: center;
    gap: 1rem;
    /* Added for a more professional feel */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); /* Subtle shadow for depth */
}

/* Ensure the space between the top border and header */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: hsl(var(--success));
    z-index: 1001;
}

.logo {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0; /* Prevent logo from shrinking */
}
.logo-icon-wrapper {
    background-color: hsl(var(--foreground));
    color: hsl(var(--background));
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    flex-shrink: 0;
}
.logo-icon-wrapper svg {
    width: 20px;
    height: 20px;
}
.logo-text {
    display: flex;
    gap: 0.25rem;
}
.logo-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1;
    transition: transform 0.2s ease-out;
}
.logo:hover .logo-char {
    transform: translateY(-2px);
}
.logo-char-green {
    background-color: hsl(var(--success));
    color: #fff;
}
.logo-char-black {
    background-color: hsl(var(--foreground));
    color: hsl(var(--background));
}

/* Desktop Navigation - Visible by default */
.header-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-grow: 1; /* Allow navigation to take available space */
}
.header-nav a {
    text-decoration: none;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    transition: var(--transition-fast);
}
.header-nav a:hover {
    color: hsl(var(--foreground));
    background-color: hsl(var(--secondary));
}
.header-nav a.active {
    color: hsl(var(--primary-foreground));
    background-color: hsl(var(--primary));
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0; /* Prevent actions from shrinking */
}
.header-stats {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
}
#header-keys-tested {
    font-weight: 600;
    color: hsl(var(--foreground));
}

/* 4. THEME TOGGLE */
.theme-toggle-btn {
    background-color: transparent;
    border: none;
    color: hsl(var(--muted-foreground));
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: var(--transition-fast);
}
.theme-toggle-btn:hover {
    background-color: hsl(var(--secondary));
    color: hsl(var(--foreground));
}
.sun-icon { display: block; } .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; } [data-theme="dark"] .moon-icon { display: block; }

/* Mobile Toggle Button (Hamburger) */
.menu-toggle {
    background-color: transparent;
    border: none;
    color: hsl(var(--foreground));
    width: 40px; /* Larger touch target */
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: none; /* Hidden by default, shown on mobile */
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: var(--transition-fast);
    z-index: 100; /* Ensure it's above other elements in the header */
}
.menu-toggle:hover {
    background-color: hsl(var(--secondary));
}
.menu-toggle .icon-close {
    display: none; /* Close icon hidden by default */
}

/* Mobile specific theme toggle positioning */
.site-header #theme-toggle {
    order: 2; /* Ensure theme toggle is to the right of the menu toggle on mobile */
}

/* Mobile Navigation Overlay */
.mobile-nav-active .header-nav {
    position: fixed;
    top: 0; /* Changed from 63px to 0 so it covers the entire screen, including header space */
    left: 0;
    width: 100%;
    height: 100vh; /* Full viewport height */
    background-color: hsla(var(--background), 0.95); /* Slightly transparent background */
    backdrop-filter: blur(8px); /* Subtle blur effect for depth */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem; /* Space out links */
    padding: 4rem 1rem; /* Padding for content */
    transform: translateX(100%); /* Start off-screen */
    transition: transform 0.3s ease-out;
    z-index: 99; /* Below header, above main content */
    overflow-y: auto; /* Enable scrolling if content overflows */
}

.mobile-nav-active .header-nav a {
    font-size: 1.5rem; /* Larger font for mobile links */
    padding: 1rem 1.5rem;
    width: 80%; /* Make links wider for easier tapping */
    max-width: 300px;
    text-align: center;
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    border-radius: var(--radius); /* Apply main border-radius */
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); /* More pronounced shadow for menu items */
    transition: var(--transition-fast);
}
.mobile-nav-active .header-nav a:hover {
    transform: translateY(-2px); /* Lift on hover/tap */
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}
.mobile-nav-active .header-nav a.active {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
    transform: none; /* No lift for active state */
    box-shadow: none; /* No shadow for active state */
}


/* Mobile specific language selector styling (inside mobile nav) */
.mobile-language-selector {
    display: none; /* Hidden by default, shown in mobile nav */
    margin-top: 2.5rem; /* More space from nav links */
    width: 100%;
    text-align: center;
    flex-direction: column; /* Stack language links vertically */
    gap: 0.75rem; /* Space between language links */
    padding: 0 1rem;
}
.mobile-nav-active .mobile-language-selector {
    display: flex; /* Show when mobile nav is active */
}
.mobile-language-selector a {
    background-color: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    padding: 0.75rem 1rem; /* Good touch target */
    font-size: 0.95rem; /* Slightly larger font */
    border-radius: var(--radius);
    text-decoration: none;
    color: hsl(var(--muted-foreground));
    transition: var(--transition-fast);
    width: 100%; /* Full width within its container */
    max-width: 250px; /* Limit max width */
    margin: 0 auto; /* Center align */
}
.mobile-language-selector a:hover {
    background-color: hsl(var(--card));
    color: hsl(var(--foreground));
    border-color: hsl(var(--primary));
}
.mobile-language-selector a.active {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}
/* Ensure flags are correctly sized and spaced */
.mobile-language-selector a::before {
    font-size: 1.2em !important; /* Make flag icons slightly larger */
    margin-right: 0.75rem !important;
}


/* --- Responsive Adjustments for Header --- */
@media (max-width: 900px) {
    /* Hide desktop nav and show menu toggle */
    .header-nav {
        display: none; /* Hide desktop navigation */
    }
    .menu-toggle {
        display: flex; /* Show hamburger icon */
    }
    .site-header {
        justify-content: space-between; /* Space out logo, toggle, theme */
        padding: 0 1rem; /* Reduce padding on smaller screens */
        height: 55px; /* Slightly shorter header */
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08); /* More subtle shadow for mobile header */
    }
    .logo-text {
        /* Hide logo text on small screens to save space and keep logo iconic */
        display: none;
    }
    /* Adjust logo icon size to be more prominent when text is hidden */
    .logo-icon-wrapper {
        width: 36px;
        height: 36px;
        border-radius: 0.6rem;
    }
    .logo-icon-wrapper svg {
        width: 22px;
        height: 22px;
    }
    .header-actions {
        gap: 0.5rem;
    }
    .header-stats { /* Hide this on mobile */
        display: none;
    }
    .theme-toggle-btn {
        width: 32px;
        height: 32px;
    }
    .theme-toggle-btn svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 768px) {
    body { padding-top: 0; }
    .site-header { position: relative; } /* Already in your CSS, but good to keep */
}

/* State for when mobile nav is active */
.mobile-nav-active .header-nav {
    transform: translateX(0); /* Slide in */
}
.mobile-nav-active .menu-toggle .icon-menu {
    display: none; /* Hide hamburger */
}
.mobile-nav-active .menu-toggle .icon-close {
    display: block; /* Show close icon */
}

/* Dark Theme Adjustments for mobile menu */
[data-theme="dark"] .site-header {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .mobile-nav-active .header-nav {
    background-color: hsla(var(--background), 0.95);
}
[data-theme="dark"] .mobile-nav-active .header-nav a {
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
[data-theme="dark"] .mobile-nav-active .header-nav a:hover {
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}
[data-theme="dark"] .mobile-nav-active .header-nav a.active {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}
[data-theme="dark"] .mobile-language-selector a {
    background-color: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    color: hsl(var(--muted-foreground));
}
[data-theme="dark"] .mobile-language-selector a.active {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}







/* 5. CARDS & SECTIONS */
.intro-section { text-align: center; max-width: 700px; margin: 2rem auto 3rem auto; }
.intro-section h1 { margin-bottom: 1rem; }
.intro-section p { font-size: 1.1rem; }
.content-card, .tool-section { background-color: hsl(var(--card)); padding: 2rem; border-radius: var(--radius); border: 1px solid hsl(var(--border)); margin-bottom: 1.5rem; }

/* 6. KEYBOARD SELECTOR */
#keyboard-selector {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    background-color: hsl(var(--secondary));
    padding: 0.5rem;
    border-radius: var(--radius);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    flex-wrap: wrap; /* Allow buttons to wrap on small screens */
    gap: 0.5rem; /* Added gap for wrapped buttons */
}
.selector-btn {
    background-color: transparent;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    border-radius: 0.4rem;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-grow: 1; /* Allow buttons to grow and fill space */
    min-width: 80px; /* Ensure a minimum width for touch */
}
.selector-btn:hover {
    color: hsl(var(--foreground));
}
.selector-btn.active {
    background-color: hsl(var(--card));
    color: hsl(var(--foreground));
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 7. KEYBOARD DESIGN */
.tool-section {
    padding: 2rem;
    background-color: hsl(var(--secondary));
    border-radius: var(--radius);
    overflow-x: auto; /* Keeps horizontal scrolling for wide keyboards */
}
#keyboard-wrapper {
    display: flex;
    gap: 1.5rem;
    width: fit-content; /* Allows content to define width for overflow-x */
    margin: 0 auto;
}
#main-keyboard, #side-keyboard {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
#side-keyboard {
    gap: 1rem;
}
.keyboard-row {
    display: flex;
    gap: 0.4rem;
}
.key {
    font-size: 0.7rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 2rem;
    min-width: 36px;
    height: 36px;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all 0.1s ease-out;
    flex-grow: 1;
    flex-basis: 36px;
    cursor: pointer;
    user-select: none; /* Prevent text selection on keys */
}
.key:hover {
    border-color: hsl(var(--primary));
    color: hsl(var(--primary));
}
.key.active {
    color: hsl(var(--primary-foreground));
    background-color: hsl(var(--primary));
    border-color: hsl(var(--primary));
}
.key.pressed {
    transform: scale(0.95);
    background-color: hsl(var(--success));
    border-color: hsl(var(--success));
    color: #fff;
}

/* Special key sizes */
.key.backspace, .key.tab, .key.capslock, .key.enter, .key.shiftleft, .key.shiftright, .key.space, .key.controlleft, .key.controlright, .key.altleft, .key.altright, .key.metaleft, .key.metaright, .key.contextmenu {
    border-radius: var(--radius);
}
.key.backspace { flex-basis: 76px; flex-grow: 2.1; }
.key.tab { flex-basis: 56px; flex-grow: 1.5; }
.key.capslock { flex-basis: 64px; flex-grow: 1.7; }
.key.enter { flex-basis: 88px; flex-grow: 2.4; }
.key.shiftleft { flex-basis: 92px; flex-grow: 2.5; }
.key.shiftright { flex-basis: 112px; flex-grow: 3.1; }
.key.space { flex-basis: 216px; flex-grow: 6; }
.key.controlleft, .key.controlright, .key.altleft, .key.altright, .key.metaleft, .key.metaright, .key.contextmenu { flex-basis: 44px; flex-grow: 1.2; }

/* Side keyboard grids */
.nav-grid, .arrow-grid, .numpad-grid { display: grid; gap: 0.4rem; }
.nav-grid { grid-template-columns: repeat(3, 36px); }
.arrow-grid { grid-template-columns: repeat(3, 36px); grid-template-areas: ". up ." "left down right"; }
#ArrowUp { grid-area: up; } #ArrowLeft { grid-area: left; } #ArrowDown { grid-area: down; } #ArrowRight { grid-area: right; }
.numpad-grid { grid-template-columns: repeat(4, 36px); }
.key.numpadadd { grid-row: span 2; height: 100%; border-radius: var(--radius); }
.key.numpadenter { grid-row: span 2; height: 100%; border-radius: var(--radius); }
.key.numpad0 { grid-column: span 2; width: 100%; border-radius: var(--radius); }

/* 8. TESTING CONTROLS */
#testing-controls { padding: 1.5rem 2rem; max-width: 840px; margin-left: auto; margin-right: auto; }
.controls-header { padding: 0 0 1rem 0; margin: 0 0 1.5rem 0; border-bottom: 1px solid hsl(var(--border)); }
.controls-header h3 { font-size: 1.1rem; gap: 0.5rem; color: hsl(var(--foreground)); display: flex; align-items: center; margin-bottom: 0.25rem;}
.controls-header h3 svg { color: hsl(var(--success)); }
.controls-header p { font-size: 0.9rem; margin: 0; }
.controls-main { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; gap: 2rem; }
.control-buttons { display: flex; gap: 0.75rem; }
.btn-primary { background-color: hsl(var(--destructive)); color: #fff; border: 1px solid hsl(var(--destructive)); padding: 8px 16px; font-size: 0.85rem; font-weight: 500; border-radius: var(--radius); cursor: pointer; }
.btn-secondary { background-color: hsl(var(--card)); color: hsl(var(--muted-foreground)); border: 1px solid hsl(var(--border)); padding: 8px 16px; font-size: 0.85rem; font-weight: 500; border-radius: var(--radius); cursor: pointer; display: flex; align-items: center; gap: 0.5rem; }
.btn-primary:hover { opacity: 0.8; }
.btn-secondary:hover { border-color: hsl(var(--foreground)); color: hsl(var(--foreground)); }
.progress-container { flex-grow: 1; display: flex; align-items: center; gap: 1rem; }
.progress-container label { font-size: 0.85rem; color: hsl(var(--muted-foreground));}
.progress-bar { height: 8px; flex-grow: 1; background-color: hsl(var(--secondary)); border-radius: 8px; overflow: hidden; }
#testing-progress-fill { width: 0%; height: 100%; background-color: hsl(var(--primary)); transition: width 0.4s ease; }
#testing-progress-text { font-size: 0.9rem; font-weight: 600; color: hsl(var(--primary)); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background-color: hsl(var(--card)); border: 1px solid hsl(var(--border)); padding:10px; border-radius: var(--radius); text-align: center; }
.stat-card span { font-size: 1rem; font-weight: 600;}
.stat-card p { font-size: 0.85rem; margin-top: 0.25rem; color: hsl(var(--muted-foreground)); }
.stat-black { color: hsl(var(--foreground)); }
.stat-yellow { color: hsl(var(--warning)); }
.stat-green { color: hsl(var(--success)); }

/* 9. FOOTER & CONTENT GRID */
.content-section { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; margin-top: 3rem; background-color: hsl(var(--secondary)); padding: 2.5rem; border-radius: var(--radius); }
.content-column h3 { font-size: 1.5rem; margin-top: 0; margin-bottom: 2rem; font-weight: 600; border-bottom: 1px solid hsl(var(--border)); padding-bottom: 1rem; }
.instruction-list, .feature-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2rem; }
.instruction-list li, .feature-list li { display: flex; align-items: flex-start; gap: 1rem; }
.instruction-list .instruction-number { background-color: hsl(var(--foreground)); color: hsl(var(--background)); border-radius: 50%; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.feature-list li svg { color: hsl(var(--success)); background-color: hsl(var(--background)); border: 1px solid hsl(var(--border)); border-radius: 50%; padding: 6px; width: 32px; height: 32px; flex-shrink: 0; }
.instruction-list h4, .feature-list h4 { font-size: 1rem; font-weight: 600; margin: 0 0 0.25rem 0; color: hsl(var(--foreground)); }
.instruction-list p, .feature-list p { font-size: 0.9rem; color: hsl(var(--muted-foreground)); margin: 0; line-height: 1.6; }
.site-footer { border-top: 1px solid hsl(var(--border)); padding: 2rem 1.5rem; margin-top: 3rem; background-color: hsl(var(--card)); }
.footer-content { max-width: 1024px; margin: 0 auto; text-align: center; }
.footer-copyright { margin: 0 0 0.25rem 0; font-size: 0.9rem; font-weight: 500; color: hsl(var(--foreground)); }
.footer-tagline { margin: 0 0 0.75rem 0; font-size: 0.85rem; color: hsl(var(--muted-foreground)); }
.footer-description { max-width: 500px; margin: 0 auto; font-size: 0.85rem; color: hsl(var(--muted-foreground)); line-height: 1.6; }


.content-with-image {
    display: block;
}
.features-page .content-with-image { grid-template-columns: 400px 1fr; }
.image-content {
    display: none; /* Hide the image container */
}
/* 10. RESPONSIVE (FIXED) */
@media (max-width: 900px) {
    /* Existing: header-nav display none */
    .site-header { grid-template-columns: 1fr auto; }
}
@media (max-width: 768px) {
    body { padding-top: 0; }
    .site-header { position: relative; }
    .controls-main { flex-direction: column; align-items: stretch; }
    .stats-grid { grid-template-columns: 1fr; }
    .content-section { grid-template-columns: 1fr; }
    #keyboard-wrapper { flex-direction: column; align-items: center; }
    .intro-section h1 { font-size: 1.8rem; } /* Adjust h1 size for mobile */
    .intro-section p { font-size: 1rem; } /* Adjust intro p size */
    main { padding: 0 1rem; margin: 1rem auto; } /* Reduce horizontal padding */
}

/* --- NEW MEDIA QUERIES FOR SMALLER SCREENS / KEYBOARD OPTIMIZATIONS --- */

@media (max-width: 600px) {
    /* Adjust overall font size slightly more for very small screens */
    html {
        font-size: 13px;
    }
    h1 {
        font-size: 1.6rem;
    }
    h3 {
        font-size: 1.3rem;
    }
    .intro-section {
        margin: 1.5rem auto 2rem auto;
    }

    /* Keyboard layout adjustments for smaller screens */
    .tool-section {
        padding: 1rem; /* Reduce padding for keyboard section */
    }
    #keyboard-wrapper {
        gap: 0.8rem; /* Reduce gap between main and side keyboard when stacked */
        /* Consider reducing overall size of the keyboard if it's too wide for typical mobile portrait view */
        /* This can be tricky with specific key sizes; overflow-x: auto is a good fallback */
    }
    .keyboard-row {
        gap: 0.3rem; /* Reduce gap between keys in a row */
    }
    .key {
        min-width: 32px; /* Slightly smaller keys */
        height: 32px;
        font-size: 0.65rem; /* Smaller font for keys */
        border-radius: 1.5rem; /* Adjust border-radius to match new size */
    }
    /* Adjust special key sizes proportionally */
    .key.backspace { flex-basis: calc(32px * 2.1); }
    .key.tab { flex-basis: calc(32px * 1.5); }
    .key.capslock { flex-basis: calc(32px * 1.7); }
    .key.enter { flex-basis: calc(32px * 2.4); }
    .key.shiftleft { flex-basis: calc(32px * 2.5); }
    .key.shiftright { flex-basis: calc(32px * 3.1); }
    .key.space { flex-basis: calc(32px * 6); }
    .key.controlleft, .key.controlright, .key.altleft, .key.altright, .key.metaleft, .key.metaright, .key.contextmenu { flex-basis: calc(32px * 1.2); }

    .nav-grid, .arrow-grid, .numpad-grid { gap: 0.3rem; }
    .nav-grid { grid-template-columns: repeat(3, 32px); }
    .arrow-grid { grid-template-columns: repeat(3, 32px); }
    .numpad-grid { grid-template-columns: repeat(4, 32px); }


    #testing-controls {
        padding: 1rem 1.5rem; /* Adjust padding */
    }
    .controls-main {
        flex-direction: column; /* Stack buttons */
        align-items: stretch;
        gap: 1.5rem; /* Adjust gap */
    }
    .control-buttons {
        flex-direction: column; /* Stack buttons */
        width: 100%;
    }
    .btn-primary, .btn-secondary {
        width: 100%; /* Make buttons full width */
        padding: 10px 16px; /* Slightly larger touch target */
        font-size: 0.9rem;
    }
    .progress-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
    }
    .progress-bar {
        width: 100%;
    }
    .stats-grid {
        gap: 0.5rem; /* Reduce gap for stat cards */
    }
    .stat-card {
        padding: 8px; /* Smaller padding for stat cards */
    }
    .stat-card span { font-size: 0.9rem; }
    .stat-card p { font-size: 0.75rem; }

    .language-links {
        flex-direction: column; /* Stack language links vertically */
        align-items: center;
    }
    .language-links a {
        width: 90%; /* Make language links wider */
        max-width: 200px; /* Limit max width */
    }
}

@media (max-width: 400px) {
    /* Even smaller adjustments for very small phones */
    main {
        padding: 0 0.5rem; /* Minimal horizontal padding */
    }
    .logo-text { /* Potentially hide part of logo text on smallest screens if it's causing overflow */
        font-size: 0.8em; /* make the logo text slightly smaller */
        gap: 0.15rem;
    }
    .logo-char {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }
    .site-header {
        height: 55px; /* Slightly shorter header */
    }
    .logo-icon-wrapper {
        width: 28px;
        height: 28px;
    }
    .logo-icon-wrapper svg {
        width: 16px;
        height: 16px;
    }
    .header-actions {
        gap: 0.5rem; /* Reduce gap in header actions */
    }
    .header-stats {
        font-size: 0.75rem;
    }
    .theme-toggle-btn {
        width: 32px;
        height: 32px;
    }
    .theme-toggle-btn svg {
        width: 18px;
        height: 18px;
    }

    .key {
        min-width: 28px; /* Even smaller keys on very small screens */
        height: 28px;
        font-size: 0.6rem;
    }
    /* Re-calculate special key sizes based on 28px base */
    .key.backspace { flex-basis: calc(28px * 2.1); }
    .key.tab { flex-basis: calc(28px * 1.5); }
    .key.capslock { flex-basis: calc(28px * 1.7); }
    .key.enter { flex-basis: calc(28px * 2.4); }
    .key.shiftleft { flex-basis: calc(28px * 2.5); }
    .key.shiftright { flex-basis: calc(28px * 3.1); }
    .key.space { flex-basis: calc(28px * 6); }
    .key.controlleft, .key.controlright, .key.altleft, .key.altright, .key.metaleft, .key.metaright, .key.contextmenu { flex-basis: calc(28px * 1.2); }

    .nav-grid, .arrow-grid, .numpad-grid { gap: 0.2rem; }
    .nav-grid { grid-template-columns: repeat(3, 28px); }
    .arrow-grid { grid-template-columns: repeat(3, 28px); }
    .numpad-grid { grid-template-columns: repeat(4, 28px); }

    .instruction-list li, .feature-list li {
        flex-direction: column; /* Stack icon/number and text vertically */
        align-items: center;
        text-align: center;
        gap: 0.5rem;
    }
    .instruction-list .instruction-number, .feature-list li svg {
        margin-bottom: 0.5rem; /* Add space below icon/number */
    }
}

/*
    IMPORTANT CONSIDERATION FOR MOBILE NAVIGATION:
    The current header completely hides `.header-nav` on screens <= 900px.
    For a truly mobile-friendly experience, you would need to:
    1.  Add a "hamburger" icon button to `header.php` (e.g., inside `.header-actions`).
    2.  Write JavaScript to toggle a class (e.g., `nav-open`) on the `<body>` or a wrapper element when the hamburger icon is clicked.
    3.  Add CSS to `style.css` for:
        -   The hamburger icon (display: block on mobile, none on desktop).
        -   Styling the `.header-nav` to be a "mobile menu" (e.g., full-screen overlay, slide-in sidebar) when the `nav-open` class is active.
        -   Styling the individual links within the mobile menu for better touch targets.
*/

.page-steps-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2.5rem;
}
.page-step {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    background-color: hsl(var(--secondary));
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
}
.step-number {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-size: 1.25rem;
    font-weight: 700;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.step-content h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}
.step-content p {
    margin: 0;
}

/* --- Styles for Features Page --- */
.page-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2.5rem;
}
.page-feature {
    background-color: hsl(var(--secondary));
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    text-align: center;
}
.feature-icon {
    background-color: hsl(var(--success));
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.page-feature h4 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}
.page-feature p {
    font-size: 0.9rem;
    margin: 0;
}



/* Language Switcher Section */
.language-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    width: 100%;
    text-align: center;
    position: relative;
}

.language-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: #007bff;
    border-radius: 0 0 3px 3px;
}

.language-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    align-items: center;
    position: relative;
}

.language-links::before {
    content: 'Language:';
    font-size: 0.9rem;
    font-weight: 600;
    color: #6c757d;
    margin-right: 1rem;
}

.language-links a {
    display: inline-flex;
    align-items: center;
    padding: 0.7rem 1.3rem;
    background: #ffffff;
    color: #495057;
    text-decoration: none;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    font-weight: 500;
    font-size: 0.9rem;
    position: relative;
    min-width: 100px;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Country Flag Icons - Add before text */
.language-links a[href*="/en"]::before {
    content: "🇺🇸";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/fr"]::before {
    content: "🇫🇷";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/es"]::before {
    content: "🇪🇸";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/de"]::before {
    content: "🇩🇪";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/it"]::before {
    content: "🇮🇹";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/pt"]::before {
    content: "🇵🇹";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/ru"]::before {
    content: "🇷🇺";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/zh"]::before {
    content: "🇨🇳";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/ja"]::before {
    content: "🇯🇵";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/ko"]::before {
    content: "🇰🇷";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/ar"]::before {
    content: "🇸🇦";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/hi"]::before {
    content: "🇮🇳";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/id"]::before {
    content: "🇮🇩";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/nl"]::before {
    content: "🇳🇱";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/tr"]::before {
    content: "🇹🇷";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a[href*="/pl"]::before {
    content: "🇵🇱";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.language-links a.active {
    background: #7ae4a4;
    color: #ffffff;

}

.language-links a.active::after {
    content: '✓';
    margin-left: 0.4rem;
    font-size: 0.8rem;
    opacity: 0.9;
}

/* --- 11. 404 ERROR PAGE STYLES --- */

.error-page-container {
    text-align: center;
    padding: 4rem 2rem; /* Add more vertical space */
    max-width: 700px;
    margin: 2rem auto;
}

.error-title {
    font-size: 6rem; /* Make the 404 number very large */
    font-weight: 700;
    color: hsl(var(--destructive)); /* Use the red color */
    line-height: 1;
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.5rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 0.5rem;
}

.error-submessage {
    font-size: 1rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 2.5rem;
}

.btn-return-home {
    display: inline-block;
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: 1px solid transparent;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius);
    text-decoration: none;
    transition: var(--transition-fast);
}

.btn-return-home:hover {
    opacity: 0.85;
}


/* Responsive Design */
@media (max-width: 768px) {
    .language-section {
        margin: 1.5rem 0;
        padding: 1.25rem;
    }

    .language-links {
        gap: 0.5rem;
    }

    .language-links::before {
        display: none;
    }

    .language-links a {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        min-width: 85px;
    }
}

@media (max-width: 480px) {
    .language-section {
        padding: 1rem;
        margin: 1rem 0;
    }

    .language-links {
        gap: 0.4rem;
    }

    .language-links a {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
        min-width: 75px;
    }

    .language-links a::before {
        font-size: 1rem;
        margin-right: 0.3rem;
    }
}

/* Alternative Compact Design */
.language-section.compact {
    padding: 1rem;
    background: #ffffff;
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.language-section.compact .language-links {
    gap: 0.4rem;
}

.language-section.compact .language-links a {
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    .language-section {
        background: #343a40;
        border-color: #495057;
    }

    .language-links::before {
        color: #adb5bd;
    }

    .language-links a {
        background: #495057;
        color: #f8f9fa;
        border-color: #6c757d;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .language-links a.active {
        background: #0d6efd;
        color: #ffffff;
        border-color: #0a58ca;
    }
}

/* RTL Support for Arabic */
.language-links a[href*="/ar"] {
    direction: rtl;
}

.language-links a[href*="/ar"]::before {
    margin-right: 0;
    margin-left: 0.5rem;
}








/* --- Footer Navigation Links --- */
.footer-nav {
    margin-top: 1.5rem;
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.footer-nav a {
    color: #4a90e2;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-nav a:hover {
    color: #2b6cb0;
    text-decoration: underline;
}

/* --- Legal Content Pages --- */
.content-card {
    max-width: 900px;
    margin: 2rem auto;
    background: #ffffff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    font-family: 'Segoe UI', sans-serif;
}

.content-card h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #333;
    text-align: center;
}

.page-description {
    text-align: center;
    color: #666;
    font-size: 1rem;
    margin-bottom: 2rem;
}

.legal-content h3 {
    color: #222;
    font-size: 1.2rem;
    margin-top: 1.5rem;
}

.legal-content p {
    color: #444;
    line-height: 1.7;
    margin-bottom: 1rem;
}

.legal-content em {
    font-style: italic;
    color: #888;
    display: block;
    margin-top: 2rem;
    font-size: 0.95rem;
}