@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Inter:wght@300;400;600&display=swap');

:root {
    --bg-color: #f7f9fc;
    --text-color: #333;
    --sub-color: #888;
    --accent-color: #000;
    --card-bg: #ffffff;
    --shadow: 0 10px 30px rgba(0,0,0,0.05);
    
    --correct-color: #2c3e50;
    --incorrect-color: #e74c3c;
    --active-bg: rgba(0,0,0,0.05);
}

body.dark-mode {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --sub-color: #666;
    --accent-color: #fff;
    --card-bg: #222;
    --shadow: 0 10px 30px rgba(0,0,0,0.3);
    
    --correct-color: #ecf0f1;
    --incorrect-color: #e74c3c;
    --active-bg: rgba(255,255,255,0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* Header */
header {
    width: 100%;
    max-width: 900px;
    padding: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(0,0,0,0.05);
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-switch {
    display: flex;
    gap: 10px;
    background: rgba(0,0,0,0.05);
    padding: 5px;
    border-radius: 8px;
}

.mode-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--sub-color);
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Main Container */
main {
    flex: 1;
    width: 100%;
    max-width: 900px;
    padding: 40px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    height: 60vh; /* Fixed height for consistency */
}

/* Free Write Area */
#freeWriteArea {
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 40px;
    font-family: 'Inter', sans-serif; /* Human writing font */
    font-size: 1.2rem;
    line-height: 1.6;
    border: none;
    resize: none;
    outline: none;
    box-shadow: var(--shadow);
    color: var(--text-color);
}

#freeWriteArea:empty:before {
    content: "Start typing clearly...";
    color: var(--sub-color);
}

/* Test Area */
#testWrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#testDisplay {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    line-height: 1.6;
    color: var(--sub-color);
    width: 100%;
    text-align: left;
    user-select: none;
    position: relative;
}

.char {
    position: relative;
    transition: color 0.1s;
}

.char.correct {
    color: var(--correct-color);
}

.char.incorrect {
    color: var(--incorrect-color);
    text-decoration: underline;
}

.char.active {
    background-color: var(--active-bg);
    color: var(--text-color);
    border-radius: 2px;
}

.char.active::after {
    content: "|";
    position: absolute;
    left: -2px;
    animation: blink 1s infinite;
    color: var(--accent-color);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

#testInput {
    opacity: 0;
    position: absolute;
    z-index: -1;
}

#restartTestBtn {
    margin-top: 20px;
    background: transparent;
    border: 2px solid var(--sub-color);
    color: var(--sub-color);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    opacity: 0;
    pointer-events: none;
}

#restartTestBtn.visible {
    opacity: 1;
    pointer-events: all;
}

#restartTestBtn:hover {
    border-color: var(--text-color);
    color: var(--text-color);
}

/* Footer */
footer {
    width: 100%;
    max-width: 900px;
    padding: 20px 0;
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    border-top: 2px solid rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

#downloadBtn {
    background: var(--accent-color);
    color: var(--bg-color);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

#downloadBtn:hover {
    transform: translateY(-2px);
}

#sessionCount {
    align-self: center;
    color: var(--sub-color);
    font-size: 0.9rem;
}

/* Utilities */
.hidden {
    display: none !important;
}
