.typing-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  min-height: calc(100vh - 53px);
}

.typing-main {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem;
  background: var(--gradient-bg, var(--background));
  background-attachment: fixed;
}

.typing-sidebar {
  background: var(--card);
  border-left: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
}

.typing-container {
  width: 100%;
  max-width: 750px;
}

/* Header */
.typing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.typing-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.02em;
}

.typing-timer {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
  transition: color 0.3s;
}

.typing-timer.active {
  color: var(--foreground);
}

.typing-timer.urgent {
  color: var(--destructive);
  animation: timerPulse 0.5s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Words display */
.words-display {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  min-height: 120px;
  max-height: 120px;
  overflow: hidden;
  position: relative;
  line-height: 2.2;
  font-size: 1.15rem;
}

.words-display::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(transparent, var(--card));
  pointer-events: none;
}

.word {
  display: inline-block;
  margin: 0 6px 4px 0;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--muted-foreground);
  transition: all 0.15s;
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.word.active {
  color: var(--foreground);
  background: rgba(168, 85, 247, 0.15);
  border-bottom: 2px solid var(--primary);
}

.word.correct {
  color: var(--success);
}

.word.wrong {
  color: var(--destructive);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

/* Input */
.typing-input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.typing-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.typing-input.wrong-flash {
  border-color: var(--destructive);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.typing-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Results */
.typing-results {
  text-align: center;
  padding: 2rem 0;
}

.result-wpm {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.result-wpm-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--foreground);
  margin-top: 0.25rem;
}

.result-wpm-sub {
  font-size: 0.8rem;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
}

.result-percentile {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 999px;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  max-width: 400px;
  margin: 0 auto 2rem;
}

.result-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-stat-label {
  color: var(--muted-foreground);
  font-size: 0.825rem;
}

.result-stat-value {
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.result-correct { color: var(--success); }
.result-wrong { color: var(--destructive); }

.result-retry {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 900px) {
  .typing-layout { grid-template-columns: 1fr; }
  .typing-sidebar { display: none; }
}

@media (max-width: 600px) {
  .typing-main { padding: 1rem; }
  .words-display { font-size: 1rem; padding: 1rem; }
  .result-wpm { font-size: 3.5rem; }
}
