/* ========================
   Keyboard Tester Styles
   ======================== */

.keyboard-tester-section {
    padding: 0 0 2rem;
}

.keyboard-tester-container {
    max-width: 1300px;
    margin: 0 auto;
}

/* Tool Header */
.tool-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-wrap: wrap;
    gap: 1rem;
}

.tool-header h1 {
    font-size: 1.8rem;
    color: white;
    margin-bottom: 0.3rem;
}

.tool-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.kb-size-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0, 242, 254, 0.15);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: 10px;
    color: #00f2fe;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-bengali);
}

.size-icon {
    font-size: 1rem;
}

.reset-all-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-bengali);
}

.reset-all-btn:hover {
    background: rgba(255, 87, 87, 0.3);
    border-color: rgba(255, 87, 87, 0.5);
    transform: translateY(-2px);
}

/* ========================
   Key Info Bar
   ======================== */

.key-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    padding: 1rem 1.5rem;
    border-radius: 14px;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.key-info-item {
    flex: 1;
    min-width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.key-info-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.key-info-value {
    color: white;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Inter', monospace;
    word-break: break-all;
    text-align: center;
}

.key-info-value.highlight {
    color: #00f2fe;
}

/* ========================
   Keyboard Layout
   ======================== */

.keyboard-visual-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.card-title {
    color: white;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.keyboard-wrapper {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: flex-start;
    min-width: fit-content;
}

.keyboard-layout {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.keyboard-nav-cluster {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 0;
}

.keyboard-numpad {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 0;
}

.hidden {
    display: none !important;
}

/* Keyboard Rows */
.kb-row {
    display: flex;
    gap: 3px;
    align-items: stretch;
}

.fn-row {
    margin-bottom: 8px;
    justify-content: space-between;
}

.fn-row .kb-key {
    flex: 1;
    min-width: 0;
}

.fn-gap {
    width: 20px;
    flex-shrink: 0;
}

.fn-gap-sm {
    width: 10px;
    flex-shrink: 0;
}

/* Individual Key */
.kb-key {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 4px 6px;
    background: linear-gradient(180deg, #3a3a40 0%, #2a2a30 100%);
    border: 1px solid rgba(80, 80, 90, 0.5);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s ease;
    box-shadow:
        0 3px 0 #1a1a1e,
        0 4px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    position: relative;
    font-family: 'Inter', monospace;
}

.kb-key span {
    pointer-events: none;
    line-height: 1;
}

.kb-key .sub {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 1px;
}

/* Key Bump (F & J) */
.key-bump {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Active Key (pressed) */
.kb-key.active {
    background: linear-gradient(180deg, #667eea 0%, #5a6fd6 100%) !important;
    border-color: rgba(102, 126, 234, 0.8);
    color: white;
    box-shadow:
        0 0 0 #1a1a1e,
        0 1px 4px rgba(102, 126, 234, 0.5),
        0 0 20px rgba(102, 126, 234, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transform: translateY(3px);
}

/* Tested Key (already pressed once) */
.kb-key.tested {
    background: linear-gradient(180deg, rgba(0, 242, 254, 0.2) 0%, rgba(0, 200, 210, 0.15) 100%);
    border-color: rgba(0, 242, 254, 0.3);
}

.kb-key.tested .sub {
    color: rgba(0, 242, 254, 0.5);
}

/* Special Key Sizes */
.key-fn {
    min-width: 42px;
    font-size: 0.65rem;
}

.key-esc {
    min-width: 42px;
}

.key-backspace {
    min-width: 90px;
    flex-grow: 1;
}

.key-tab {
    min-width: 65px;
}

.key-backslash {
    min-width: 65px;
    flex-grow: 1;
}

.key-caps {
    min-width: 78px;
}

.key-enter {
    min-width: 95px;
    flex-grow: 1;
}

.key-shift-l {
    min-width: 105px;
}

.key-shift-r {
    min-width: 118px;
    flex-grow: 1;
}

.key-ctrl {
    min-width: 58px;
}

.key-meta {
    min-width: 50px;
}

.key-alt {
    min-width: 50px;
}

.key-menu {
    min-width: 50px;
}

.key-space {
    min-width: 280px;
    flex-grow: 1;
}

.key-sm {
    min-width: 42px;
}

.key-arrow {
    min-width: 42px;
    height: 42px;
}

/* Nav Cluster Layout */
.nav-fn-row {
    margin-bottom: 8px;
}

.nav-spacer {
    height: 42px;
    /* Aligns with the ASDF/Caps Lock row which is 42px height */
}

.arrow-keys-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Changed from 3px to 4px to match layout */
}

.arrow-row {
    justify-content: center;
}

.arrow-row-bottom {
    justify-content: center;
}

/* Numpad Grid */
.numpad-grid {
    display: grid;
    grid-template-columns: repeat(4, 42px);
    grid-template-rows: repeat(5, 42px);
    gap: 4px;
    /* Changed from 3px to 4px */
}

.numpad-r1c1 {
    grid-area: 1 / 1;
}

.numpad-r1c2 {
    grid-area: 1 / 2;
}

.numpad-r1c3 {
    grid-area: 1 / 3;
}

.numpad-r1c4 {
    grid-area: 1 / 4;
}

.numpad-r2c1 {
    grid-area: 2 / 1;
}

.numpad-r2c2 {
    grid-area: 2 / 2;
}

.numpad-r2c3 {
    grid-area: 2 / 3;
}

.numpad-r2c4 {
    grid-area: 2 / 4 / 4 / 5;
}

/* + key: spans rows 2-3 */

.numpad-r3c1 {
    grid-area: 3 / 1;
}

.numpad-r3c2 {
    grid-area: 3 / 2;
}

.numpad-r3c3 {
    grid-area: 3 / 3;
}

.numpad-r4c1 {
    grid-area: 4 / 1;
}

.numpad-r4c2 {
    grid-area: 4 / 2;
}

.numpad-r4c3 {
    grid-area: 4 / 3;
}

.numpad-r4c4 {
    grid-area: 4 / 4 / 6 / 5;
}

/* Enter key: spans rows 4-5 */

.numpad-r5c1 {
    grid-area: 5 / 1 / 6 / 3;
}

/* 0 key: spans cols 1-2 */
.numpad-r5c3 {
    grid-area: 5 / 3;
}

/* Numpad Specials — grid version */
.key-numpad-plus {
    min-width: auto;
    height: auto;
}

.key-numpad-enter {
    min-width: auto;
    height: auto;
}

.key-numpad-zero {
    min-width: auto;
}

/* LED Indicators */
.numpad-indicators {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    height: 42px;
    /* Matches height of F-keys */
    box-sizing: border-box;
}

.led-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.led-indicator span {
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.led-light {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.led-indicator.active .led-light {
    background: #00ff88;
    box-shadow: 0 0 6px #00ff88, 0 0 12px rgba(0, 255, 136, 0.4);
    border-color: #00ff88;
}

.led-indicator.active span {
    color: #00ff88;
}

/* ========================
   Typing Test Card
   ======================== */

.typing-test-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.typing-instruction {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    font-family: var(--font-bengali);
}

.sample-text {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem 1.2rem;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95rem;
    font-family: 'Inter', monospace;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
    line-height: 1.6;
    word-break: break-all;
}

.sample-text .char {
    transition: color 0.15s ease;
}

.sample-text .char.correct {
    color: #00f2fe;
}

.sample-text .char.wrong {
    color: #f5576c;
    text-decoration: underline;
}

.sample-text .char.current {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
    padding: 0 1px;
}

.typing-area {
    width: 100%;
    padding: 1rem 1.2rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: white;
    font-size: 0.95rem;
    font-family: 'Inter', monospace;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
}

.typing-area:focus {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.2);
}

.typing-area::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-family: var(--font-bengali);
}

.typing-stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.8rem;
    flex-wrap: wrap;
}

.typing-stats .stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.typing-stats .stat-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.82rem;
    font-family: var(--font-bengali);
}

.typing-stats .stat-value {
    font-weight: 700;
    font-family: 'Inter', monospace;
    color: white;
}

.typing-stats .stat-value.correct {
    color: #00f2fe;
}

.typing-stats .stat-value.wrong {
    color: #f5576c;
}

/* ========================
   History Log
   ======================== */

.history-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.history-header .card-title {
    margin-bottom: 0;
}

.clear-log-btn {
    padding: 6px 16px;
    background: rgba(255, 87, 87, 0.2);
    border: 1px solid rgba(255, 87, 87, 0.3);
    border-radius: 8px;
    color: #ff5757;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-bengali);
}

.clear-log-btn:hover {
    background: rgba(255, 87, 87, 0.35);
}

.history-log {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

.history-log::-webkit-scrollbar {
    width: 4px;
}

.history-log::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.history-log::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.log-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    padding: 2rem;
    font-size: 0.9rem;
    font-family: var(--font-bengali);
}

.log-entry {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.8rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-size: 0.82rem;
    animation: logSlideIn 0.3s ease;
}

@keyframes logSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-time {
    color: rgba(255, 255, 255, 0.4);
    font-family: 'Inter', monospace;
    font-size: 0.72rem;
    flex-shrink: 0;
}

.log-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.log-text {
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Inter', monospace;
    word-break: break-all;
}

.log-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: auto;
    flex-shrink: 0;
}

.log-badge.keydown {
    background: rgba(102, 126, 234, 0.25);
    color: #667eea;
}

.log-badge.keyup {
    background: rgba(0, 242, 254, 0.25);
    color: #00f2fe;
}

/* ========================
   Dark Mode Overrides
   ======================== */

body.dark-mode .tool-header,
body.dark-mode .key-info-bar,
body.dark-mode .keyboard-visual-card,
body.dark-mode .typing-test-card,
body.dark-mode .history-card {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .key-info-item {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.06);
}

body.dark-mode .kb-key {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-color: rgba(51, 65, 85, 0.6);
    box-shadow:
        0 3px 0 #020617,
        0 4px 6px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.dark-mode .kb-key.tested {
    background: linear-gradient(180deg, rgba(0, 242, 254, 0.15) 0%, rgba(0, 200, 210, 0.1) 100%);
}

body.dark-mode .sample-text {
    background: rgba(0, 0, 0, 0.4);
}

body.dark-mode .typing-area {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .log-entry {
    background: rgba(255, 255, 255, 0.04);
}

/* ========================
   Responsive
   ======================== */

@media (max-width: 1024px) {
    .keyboard-wrapper {
        flex-wrap: wrap;
    }

    .keyboard-nav-cluster,
    .keyboard-numpad {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .tool-header {
        flex-direction: column;
        text-align: center;
    }

    .tool-header h1 {
        font-size: 1.4rem;
    }

    .header-actions {
        justify-content: center;
    }

    .key-info-bar {
        gap: 0.5rem;
    }

    .key-info-item {
        min-width: 80px;
    }

    .keyboard-visual-card {
        padding: 1rem;
    }

    .kb-key {
        min-width: 28px;
        height: 34px;
        font-size: 0.6rem;
        padding: 2px 3px;
    }

    .key-space {
        min-width: 160px;
    }

    .key-backspace {
        min-width: 60px;
    }

    .key-tab {
        min-width: 45px;
    }

    .key-caps {
        min-width: 52px;
    }

    .key-enter {
        min-width: 62px;
    }

    .key-shift-l {
        min-width: 68px;
    }

    .key-shift-r {
        min-width: 75px;
    }

    .key-ctrl {
        min-width: 38px;
    }

    .key-meta {
        min-width: 34px;
    }

    .key-alt {
        min-width: 34px;
    }

    .key-backslash {
        min-width: 42px;
    }

    .key-fn {
        min-width: 28px;
        font-size: 0.55rem;
    }

    .fn-gap {
        width: 8px;
    }

    .fn-gap-sm {
        width: 4px;
    }
}

@media (max-width: 480px) {
    .kb-key {
        min-width: 22px;
        height: 28px;
        font-size: 0.5rem;
        border-radius: 4px;
    }

    .key-space {
        min-width: 120px;
    }

    .key-backspace {
        min-width: 48px;
    }

    .key-tab {
        min-width: 36px;
    }

    .key-caps {
        min-width: 42px;
    }

    .key-enter {
        min-width: 50px;
    }

    .key-shift-l {
        min-width: 54px;
    }

    .key-shift-r {
        min-width: 60px;
    }

    .kb-row {
        gap: 2px;
    }

    .keyboard-layout {
        gap: 2px;
    }
}

/* ========================
   Guide Section
   ======================== */

.guide-section {
    margin-top: 2rem;
}

.guide-main-title {
    color: white;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-align: center;
    font-family: var(--font-bengali);
}

.guide-main-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    text-align: center;
    margin-bottom: 2rem;
    font-family: var(--font-bengali);
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
    margin-bottom: 2rem;
}

.guide-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 1.8rem;
    transition: all 0.3s ease;
}

.guide-card:hover {
    transform: translateY(-4px);
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.guide-card-icon {
    font-size: 2.2rem;
    margin-bottom: 0.8rem;
    line-height: 1;
}

.guide-card h3 {
    color: white;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    font-family: var(--font-bengali);
}

.guide-card p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 0.8rem;
    font-family: var(--font-bengali);
}

.guide-card p:last-child {
    margin-bottom: 0;
}

.guide-card ul,
.guide-card ol {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.88rem;
    line-height: 1.8;
    padding-left: 1.2rem;
    margin-bottom: 0.8rem;
    font-family: var(--font-bengali);
}

.guide-card li {
    margin-bottom: 0.4rem;
}

.guide-card li strong {
    color: rgba(255, 255, 255, 0.95);
}

/* FAQ Section */
.faq-section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 2rem;
}

.faq-title {
    color: white;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
    font-family: var(--font-bengali);
}

.faq-item {
    padding: 1.2rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.faq-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.faq-q {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    font-family: var(--font-bengali);
}

.faq-a {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    line-height: 1.8;
    font-family: var(--font-bengali);
}

/* Dark Mode Guide */
body.dark-mode .guide-card,
body.dark-mode .faq-section {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .faq-item {
    border-color: rgba(255, 255, 255, 0.05);
}

/* Guide Responsive */
@media (max-width: 768px) {
    .guide-grid {
        grid-template-columns: 1fr;
    }

    .guide-main-title {
        font-size: 1.4rem;
    }

    .guide-card {
        padding: 1.3rem;
    }

    .faq-section {
        padding: 1.3rem;
    }
}

/* ============================================
   LARGE DESKTOP RESPONSIVE - Match Header Width
   ============================================ */

/* Full HD Desktop (1920-2047px) */
@media (min-width: 1920px) and (max-width: 2047px) {
    .keyboard-tester-container {
        max-width: 1500px;
    }

    .key {
        min-width: 52px;
        height: 52px;
        font-size: 0.85rem;
    }

    .keyboard-container {
        padding: 1.8rem;
    }

    .typing-test-area {
        font-size: 1.1rem;
    }

    .guide-grid {
        gap: 1.5rem;
    }
}

/* iMac Retina 4k 21.5" (2048x1152) */
@media (min-width: 2048px) and (max-width: 2239px) {
    .keyboard-tester-container {
        max-width: 1650px;
    }

    .key {
        min-width: 56px;
        height: 56px;
        font-size: 0.9rem;
    }

    .keyboard-container {
        padding: 2rem;
    }

    .tool-header h1 {
        font-size: 1.8rem;
    }

    .tool-subtitle {
        font-size: 0.95rem;
    }

    .typing-test-area {
        font-size: 1.15rem;
        padding: 1.2rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .guide-main-title {
        font-size: 2rem;
    }
}

/* iMac Retina 4.5k 24" (2240x1800) */
@media (min-width: 2240px) and (max-width: 2559px) {
    .keyboard-tester-container {
        max-width: 1800px;
    }

    .key {
        min-width: 60px;
        height: 60px;
        font-size: 0.95rem;
    }

    .keyboard-container {
        padding: 2.2rem;
        border-radius: 20px;
    }

    .tool-header {
        padding: 1.5rem 2rem;
    }

    .tool-header h1 {
        font-size: 2rem;
    }

    .tool-subtitle {
        font-size: 1rem;
    }

    .typing-test-area {
        font-size: 1.2rem;
        padding: 1.3rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .guide-main-title {
        font-size: 2.2rem;
    }

    .guide-card {
        padding: 1.8rem;
    }

    .guide-card h3 {
        font-size: 1.15rem;
    }
}

/* QHD Desktop / Desktop hidpi XL (2560x1440) */
@media (min-width: 2560px) and (max-width: 3199px) {
    .keyboard-tester-container {
        max-width: 2000px;
    }

    .key {
        min-width: 66px;
        height: 66px;
        font-size: 1rem;
        border-radius: 10px;
    }

    .keyboard-container {
        padding: 2.5rem;
        border-radius: 22px;
    }

    .tool-header {
        padding: 1.6rem 2.2rem;
        border-radius: 20px;
    }

    .tool-header h1 {
        font-size: 2.2rem;
    }

    .tool-subtitle {
        font-size: 1.1rem;
    }

    .typing-test-area {
        font-size: 1.3rem;
        padding: 1.5rem;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .guide-main-title {
        font-size: 2.4rem;
    }

    .guide-card {
        padding: 2rem;
    }

    .guide-card h3 {
        font-size: 1.2rem;
    }

    .faq-question span {
        font-size: 1.1rem;
    }
}

/* iMac pro Retina 5k 27" (3200x1800) */
@media (min-width: 3200px) and (max-width: 3839px) {
    .keyboard-tester-container {
        max-width: 2400px;
    }

    .key {
        min-width: 74px;
        height: 74px;
        font-size: 1.1rem;
        border-radius: 12px;
    }

    .keyboard-container {
        padding: 3rem;
        border-radius: 26px;
    }

    .tool-header {
        padding: 1.8rem 2.5rem;
        border-radius: 22px;
    }

    .tool-header h1 {
        font-size: 2.5rem;
    }

    .tool-subtitle {
        font-size: 1.2rem;
    }

    .typing-test-area {
        font-size: 1.4rem;
        padding: 1.8rem;
    }

    .guide-main-title {
        font-size: 2.6rem;
    }
}

/* Desktop 4K (3840x2160+) */
@media (min-width: 3840px) {
    .keyboard-tester-container {
        max-width: 2800px;
    }

    .key {
        min-width: 82px;
        height: 82px;
        font-size: 1.2rem;
        border-radius: 14px;
    }

    .keyboard-container {
        padding: 3.5rem;
        border-radius: 30px;
    }

    .tool-header {
        padding: 2rem 3rem;
        border-radius: 26px;
    }

    .tool-header h1 {
        font-size: 2.8rem;
    }

    .tool-subtitle {
        font-size: 1.4rem;
    }

    .typing-test-area {
        font-size: 1.6rem;
        padding: 2rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    .guide-main-title {
        font-size: 3rem;
    }

    .guide-card {
        padding: 2.5rem;
    }

    .guide-card h3 {
        font-size: 1.4rem;
    }

    .faq-question span {
        font-size: 1.3rem;
    }
}

/* ========================
   Theme Architecture Updates (Light/Dark Mode Fixes)
   ======================== */

.tool-header, 
.key-info-bar, 
.keyboard-visual-card, 
.typing-test-card, 
.history-card, 
.guide-card, 
.faq-section {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.key-info-item, .sample-text, .typing-area, .log-entry {
    background: var(--bg-card);
    border-color: var(--border-color);
}

/* Text that should be dark in Light Mode */
.tool-header h1, 
.key-info-value, 
.card-title, 
.typing-stats .stat-value, 
.guide-main-title, 
.guide-card h3, 
.faq-title, 
.faq-q, 
.log-text {
    color: var(--text-dark);
}

/* Buttons and UI */
.reset-all-btn {
    color: var(--text-dark);
}
body.dark-mode .reset-all-btn {
    color: #ffffff;
}

.kb-size-indicator {
    color: var(--primary-color);
    background: var(--bg-card);
    border-color: var(--border-color);
}
body.dark-mode .kb-size-indicator {
    color: #00f2fe;
    background: rgba(0, 242, 254, 0.15);
    border-color: rgba(0, 242, 254, 0.3);
}

.led-indicator span {
    color: var(--text-muted);
}
body.dark-mode .led-indicator span {
    color: rgba(255, 255, 255, 0.4);
}

/* Text that should be muted in Light Mode */
.tool-subtitle, 
.key-info-label, 
.typing-instruction, 
.typing-stats .stat-label, 
.guide-main-subtitle, 
.guide-card p, 
.guide-card ul, 
.guide-card ol, 
.faq-a, 
.log-time, 
.log-empty,
.sample-text {
    color: var(--text-muted);
}

/* Keep typing correct/wrong highlighted */
.sample-text .char.correct, .typing-stats .stat-value.correct {
    color: #00bcd4; /* slightly darker cyan for readability in both modes */
}
body.dark-mode .sample-text .char.correct, body.dark-mode .typing-stats .stat-value.correct {
    color: #00f2fe;
}

.sample-text .char.wrong, .typing-stats .stat-value.wrong {
    color: #e53935; /* readable red */
}
body.dark-mode .sample-text .char.wrong, body.dark-mode .typing-stats .stat-value.wrong {
    color: #f5576c;
}

.key-info-value.highlight {
    color: var(--primary-color);
}
body.dark-mode .key-info-value.highlight {
    color: #00f2fe;
}

/* Typing area text */
.typing-area {
    color: var(--text-dark);
}
.typing-area::placeholder {
    color: var(--text-muted);
}

/* Dark Mode explicit fixes to retain contrast */
body.dark-mode .sample-text {
    background: rgba(0, 0, 0, 0.4);
    color: rgba(255, 255, 255, 0.6);
}
body.dark-mode .sample-text .char.current {
    background: rgba(102, 126, 234, 0.3);
}
body.dark-mode .sample-text .char.wrong {
    color: #f5576c;
}

/* Shadow for light mode */
.keyboard-visual-card, .history-card, .guide-card, .faq-section {
    box-shadow: var(--shadow-color) 0px 4px 12px;
}

/* Button Backgrounds for Light Mode */
.reset-all-btn {
    background: var(--bg-card);
    border-color: var(--border-color);
}
body.dark-mode .reset-all-btn {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}
body:not(.dark-mode) .reset-all-btn:hover {
    background: rgba(255, 87, 87, 0.1);
    border-color: rgba(255, 87, 87, 0.3);
    color: #e53935;
}

.clear-log-btn {
    color: #e53935;
    background: rgba(229, 57, 53, 0.1);
    border-color: rgba(229, 57, 53, 0.2);
}
body.dark-mode .clear-log-btn {
    color: #ff5757;
    background: rgba(255, 87, 87, 0.2);
    border-color: rgba(255, 87, 87, 0.3);
}