/* ==========================================================
   IT TRACK INSTITUTE - PRO TYPING MASTER
   Apple-Inspired Human Interface Design System
   ========================================================== */

:root {
  /* Dark Mode Default Palette (Apple Space Black & Graphite) */
  --bg-primary: #000000;
  --bg-secondary: #121215;
  --bg-tertiary: #1c1c21;
  --bg-card: rgba(28, 28, 33, 0.65);
  --bg-card-hover: rgba(38, 38, 45, 0.75);
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-active: rgba(255, 255, 255, 0.22);
  
  --text-primary: #f5f5f7;
  --text-secondary: #86868b;
  --text-muted: #53535a;
  
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-blue-glow: rgba(0, 113, 227, 0.35);
  --apple-cyan: #2997ff;
  --apple-green: #30d158;
  --apple-green-glow: rgba(48, 209, 88, 0.25);
  --apple-red: #ff453a;
  --apple-red-glow: rgba(255, 69, 58, 0.3);
  --apple-yellow: #ffd60a;
  
  /* Finger Color Legend */
  --finger-pinky: #ff375f;
  --finger-ring: #ff9f0a;
  --finger-middle: #30d158;
  --finger-index: #0a84ff;
  --finger-thumb: #bf5af2;
  
  /* Typography */
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 980px;

  --nav-height: 64px;
  --transition-smooth: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e5e5ea;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-active: rgba(0, 0, 0, 0.18);
  
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-blue-glow: rgba(0, 113, 227, 0.15);
  --apple-green: #28cd41;
  --apple-red: #ff3b30;
}

/* Base Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* Ambient Radial Glows (Apple Keynote Style) */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(140px);
  z-index: 0;
  opacity: 0.15;
  transition: opacity 0.5s ease;
}

.glow-1 {
  width: 600px;
  height: 400px;
  background: radial-gradient(circle, #0071e3 0%, rgba(41, 151, 255, 0) 70%);
  top: -100px;
  left: 20%;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #af52de 0%, rgba(191, 90, 242, 0) 70%);
  bottom: 10%;
  right: 10%;
}

/* Navigation Bar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(18, 18, 21, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition-smooth);
}

[data-theme="light"] .navbar {
  background: rgba(245, 245, 247, 0.78);
}

.nav-container {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0071e3, #2997ff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px var(--apple-blue-glow);
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  background: var(--bg-tertiary);
  color: var(--apple-cyan);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.nav-links {
  display: flex;
  gap: 6px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.nav-pill {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nav-pill:hover {
  color: var(--text-primary);
}

.nav-pill.active {
  background: var(--apple-blue);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--apple-blue-glow);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
  background: var(--bg-tertiary);
}

.student-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
}

.student-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #af52de, #5856d6);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.student-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.hidden {
  display: none !important;
}

/* Main Container */
.main-container {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 36px 24px 60px;
  flex: 1;
  position: relative;
  z-index: 1;
}

/* Hero Section */
.hero-section {
  text-align: center;
  margin-bottom: 32px;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--apple-cyan);
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--apple-green);
  box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.7);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(48, 209, 88, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(48, 209, 88, 0); }
}

.hero-title {
  font-size: 2.85rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  margin-bottom: 14px;
  background: linear-gradient(180deg, var(--text-primary) 30%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .hero-title {
  background: linear-gradient(180deg, #1d1d1f 30%, #515154 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  max-width: 640px;
  margin: 0 auto;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.hero-desc strong {
  color: var(--text-primary);
}

/* Content Sections Visibility */
.content-section {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.content-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Segmented Controls (Apple iOS/macOS Style) */
.controls-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
}

.segmented-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segment-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.segmented-control {
  display: inline-flex;
  background: var(--bg-secondary);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  position: relative;
}

.seg-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn.active {
  background: var(--apple-blue);
  color: #fff;
  box-shadow: 0 2px 8px var(--apple-blue-glow);
}

.pill-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.pill-toggle .toggle-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition-smooth);
}

.pill-toggle.active {
  color: var(--text-primary);
  border-color: var(--apple-blue);
}

.pill-toggle.active .toggle-indicator {
  background: var(--apple-green);
  box-shadow: 0 0 6px var(--apple-green);
}

/* Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.metric-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.metric-name {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.metric-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.metric-value {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.metric-value.accent-green { color: var(--apple-green); }
.metric-value.accent-blue { color: var(--apple-cyan); }
.metric-value.accent-red { color: var(--apple-red); }

.metric-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  margin-top: 10px;
  overflow: hidden;
}

.metric-fill {
  height: 100%;
  background: var(--apple-blue);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.metric-fill.bg-green { background: var(--apple-green); }
.metric-fill.bg-blue { background: var(--apple-cyan); }
.metric-fill.bg-red { background: var(--apple-red); }

/* Typing Stage (The Apple Arena) */
.typing-stage {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px 36px 28px;
  backdrop-filter: blur(30px);
  position: relative;
  margin-bottom: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  user-select: none;
}

.typing-stage.focused {
  border-color: rgba(0, 113, 227, 0.5);
  box-shadow: 0 10px 40px var(--apple-blue-glow);
}

.hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* Stage Overlay When Unfocused */
.stage-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

[data-theme="light"] .stage-overlay {
  background: rgba(255, 255, 255, 0.5);
}

.typing-stage:not(.focused) .stage-overlay {
  opacity: 1;
  pointer-events: auto;
}

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
  background: rgba(28, 28, 33, 0.85);
  padding: 14px 24px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

[data-theme="light"] .overlay-content {
  background: rgba(255, 255, 255, 0.9);
  color: #1d1d1f;
}

/* Words Stream Container */
.words-container {
  min-height: 140px;
  max-height: 180px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 1.45rem;
  line-height: 2.2;
  position: relative;
  letter-spacing: -0.01em;
  display: flex;
  flex-wrap: wrap;
  gap: 0 14px;
}

.word {
  display: inline-flex;
  position: relative;
  margin-bottom: 4px;
  white-space: pre;
}

.word.active {
  border-radius: 4px;
}

.letter {
  position: relative;
  color: var(--text-muted);
  transition: color 0.12s ease;
}

.letter.correct {
  color: var(--apple-green);
}

.letter.incorrect {
  color: var(--apple-red);
  background: rgba(255, 69, 58, 0.15);
  border-radius: 2px;
}

.letter.extra {
  color: #ff453a;
  opacity: 0.65;
}

/* Smooth Apple Caret / Cursor */
.caret {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 2.5px;
  background: var(--apple-cyan);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--apple-cyan);
  pointer-events: none;
  animation: pulseCaret 1.1s infinite;
  transition: left 0.08s ease, top 0.08s ease;
  z-index: 5;
}

@keyframes pulseCaret {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Stage Actions / Restart */
.stage-actions {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.apple-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.apple-action-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.shortcut-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: var(--bg-card);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* ==========================================================
   VIRTUAL APPLE MAGIC KEYBOARD
   ========================================================== */
.keyboard-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  backdrop-filter: blur(25px);
  margin-bottom: 24px;
  transition: var(--transition-smooth);
}

.keyboard-wrapper.collapsed {
  display: none;
}

.keyboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.kh-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.finger-legends {
  display: flex;
  gap: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.f-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.f-pinky { background-color: var(--finger-pinky); }
.f-ring { background-color: var(--finger-ring); }
.f-middle { background-color: var(--finger-middle); }
.f-index { background-color: var(--finger-index); }
.f-thumb { background-color: var(--finger-thumb); }

.magic-keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  user-select: none;
}

.k-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.key {
  position: relative;
  height: 44px;
  min-width: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  transition: transform 0.05s ease, background-color 0.1s ease, border-color 0.1s ease;
  padding: 2px 6px;
  font-family: var(--font-mono);
}

[data-theme="light"] .key {
  background: #ffffff;
  border-color: #d1d1d6;
  box-shadow: 0 2px 0 #b0b0b5;
}

.key .main {
  font-size: 0.8rem;
}

.key .sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  position: absolute;
  top: 3px;
  right: 5px;
}

/* Home row tactile bump */
.key.home-bump .bump {
  position: absolute;
  bottom: 5px;
  width: 10px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
}

/* Special Key Widths */
.key-delete { min-width: 68px; font-size: 0.7rem; align-items: flex-end; padding-right: 8px; }
.key-tab { min-width: 68px; font-size: 0.7rem; align-items: flex-start; padding-left: 8px; }
.key-caps { min-width: 78px; font-size: 0.7rem; align-items: flex-start; padding-left: 8px; }
.key-return { min-width: 78px; font-size: 0.7rem; align-items: flex-end; padding-right: 8px; }
.key-shift-l { min-width: 98px; font-size: 0.7rem; align-items: flex-start; padding-left: 8px; }
.key-shift-r { min-width: 98px; font-size: 0.7rem; align-items: flex-end; padding-right: 8px; }
.key-space { flex: 1; max-width: 290px; }
.key-cmd, .key-opt, .key-ctrl, .key-fn { min-width: 52px; font-size: 0.68rem; }

/* Active key press animation */
.key.pressed {
  transform: translateY(2px);
  background: var(--apple-blue) !important;
  color: #fff !important;
  border-color: var(--apple-blue) !important;
  box-shadow: none !important;
}

/* Target key highlight (the key the user needs to press next) */
.key.target-key {
  border-color: var(--apple-cyan);
  box-shadow: 0 0 12px var(--apple-blue-glow), inset 0 0 8px rgba(41, 151, 255, 0.35);
  animation: keyPulse 1.2s infinite alternate;
}

@keyframes keyPulse {
  from { border-color: var(--apple-cyan); }
  to { border-color: #ffffff; }
}

/* Finger highlight tints */
.key.f-pinky::before { content: ""; position: absolute; bottom: 2px; left: 6px; right: 6px; height: 2px; background: var(--finger-pinky); border-radius: 2px; opacity: 0.6; }
.key.f-ring::before { content: ""; position: absolute; bottom: 2px; left: 6px; right: 6px; height: 2px; background: var(--finger-ring); border-radius: 2px; opacity: 0.6; }
.key.f-middle::before { content: ""; position: absolute; bottom: 2px; left: 6px; right: 6px; height: 2px; background: var(--finger-middle); border-radius: 2px; opacity: 0.6; }
.key.f-index::before { content: ""; position: absolute; bottom: 2px; left: 6px; right: 6px; height: 2px; background: var(--finger-index); border-radius: 2px; opacity: 0.6; }
.key.f-thumb::before { content: ""; position: absolute; bottom: 2px; left: 20px; right: 20px; height: 2px; background: var(--finger-thumb); border-radius: 2px; opacity: 0.6; }

/* ==========================================================
   ACADEMY LESSONS GRID
   ========================================================== */
.section-heading {
  text-align: center;
  margin-bottom: 32px;
}

.section-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--apple-cyan);
  margin-bottom: 8px;
}

.section-heading h2 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.section-heading p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.lessons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.lesson-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(20px);
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.lesson-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-active);
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

.lesson-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.lesson-number {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--apple-cyan);
}

.lesson-difficulty {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--apple-green);
}

.lesson-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.lesson-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 18px;
}

.lesson-keys-preview {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.l-key-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 4px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
}

.lesson-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.lesson-card:hover .lesson-btn {
  background: var(--apple-blue);
  color: #fff;
}

/* ==========================================================
   RECORDS & HISTORY SECTION
   ========================================================== */
.records-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.records-summary-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(20px);
}

.record-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.stat-num {
  font-size: 2.2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--apple-cyan);
}

.stat-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.records-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(20px);
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.table-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.text-btn {
  background: none;
  border: none;
  color: var(--apple-red);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.text-btn:hover {
  text-decoration: underline;
}

.table-wrapper {
  overflow-x: auto;
}

.apple-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.apple-table th {
  padding: 12px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.apple-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.apple-table tr:hover td {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.badge-status {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-passed {
  background: rgba(48, 209, 88, 0.15);
  color: var(--apple-green);
}

.empty-state {
  text-align: center;
  padding: 36px !important;
  color: var(--text-muted) !important;
}

/* ==========================================================
   GUIDE SECTION
   ========================================================== */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(20px);
}

.guide-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--apple-blue);
  margin-bottom: 16px;
}

.guide-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.guide-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ==========================================================
   MODALS (Apple Style Sheet)
   ========================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 20px;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: scale(0.94) translateY(12px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.modal-backdrop.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(48, 209, 88, 0.15);
  color: var(--apple-green);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text-primary);
}

.result-hero {
  text-align: center;
  padding: 10px 0 24px;
}

.result-big-wpm {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.wpm-number {
  font-size: 4.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, #2997ff, #30d158);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.wpm-unit {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.result-rank-pill {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--apple-yellow);
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.sub-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ss-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.ss-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.text-green { color: var(--apple-green); }

.student-certificate-action {
  border-top: 1px solid var(--border-subtle);
  padding-top: 20px;
}

.name-input-group {
  margin-bottom: 16px;
}

.name-input-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.name-input-group input {
  width: 100%;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.name-input-group input:focus {
  border-color: var(--apple-blue);
}

.modal-actions-row {
  display: flex;
  gap: 10px;
}

.apple-btn-primary {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--apple-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 14px var(--apple-blue-glow);
}

.apple-btn-primary:hover {
  background: var(--apple-blue-hover);
  transform: translateY(-1px);
}

.apple-btn-secondary {
  padding: 12px 20px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.apple-btn-secondary:hover {
  background: var(--bg-card-hover);
}

/* ==========================================================
   OFFICIAL CERTIFICATE MODAL & PRINT STYLING
   ========================================================== */
.cert-card-wrapper {
  max-width: 780px;
  padding: 24px;
  background: #ffffff;
  color: #1a1a1a;
}

.certificate-sheet {
  background: #ffffff;
  color: #111;
  padding: 24px;
}

.cert-border-outer {
  border: 8px double #1a2a4b;
  padding: 8px;
  position: relative;
  background: #fffdf9;
}

.cert-border-inner {
  border: 2px solid #b08d57;
  padding: 36px 30px;
  position: relative;
  text-align: center;
}

.cert-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-25deg);
  font-size: 5.5rem;
  font-weight: 900;
  color: rgba(0, 0, 0, 0.035);
  pointer-events: none;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.cert-logo-box {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: #1a2a4b;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-institute-title {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #1a2a4b;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.cert-subtitle {
  font-size: 0.85rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 24px;
}

.cert-declaration {
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  color: #777;
  font-weight: 700;
  margin-bottom: 8px;
}

.cert-recipient {
  font-size: 2.4rem;
  font-weight: 800;
  font-family: Georgia, serif;
  color: #0d1b2a;
  border-bottom: 2px solid #b08d57;
  display: inline-block;
  padding: 0 30px 4px;
  margin-bottom: 16px;
}

.cert-statement {
  font-size: 0.95rem;
  color: #444;
  max-width: 580px;
  margin: 0 auto 24px;
  line-height: 1.5;
}

.cert-metrics-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 32px;
}

.cert-stat-badge {
  background: #f4f6fa;
  border: 1px solid #dcdde1;
  padding: 10px 22px;
  border-radius: 8px;
}

.cs-num {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  color: #1a2a4b;
  font-family: var(--font-mono);
}

.cs-lbl {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #777;
}

.cert-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 10px;
}

.cert-signature {
  text-align: center;
  width: 170px;
}

.sig-line {
  border-bottom: 1px solid #333;
  padding-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #222;
  font-family: Georgia, serif;
}

.sig-title {
  display: block;
  font-size: 0.65rem;
  color: #888;
  margin-top: 4px;
  text-transform: uppercase;
}

.cert-seal {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 2px dashed #b08d57;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seal-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #b08d57;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
}

.cert-modal-actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

/* Print CSS */
@media print {
  body * {
    visibility: hidden;
  }
  #certificateModal, #certificateModal * {
    visibility: visible;
  }
  #certificateModal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: #fff !important;
    padding: 0 !important;
  }
  .cert-modal-actions, .modal-close {
    display: none !important;
  }
  .cert-card-wrapper {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
  }
}

/* Confetti Canvas */
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1001;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  padding: 20px 24px;
  margin-top: auto;
}

.footer-content {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 12px;
}

.dot-separator {
  margin: 0 8px;
  opacity: 0.4;
}

.version-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

/* ==========================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ========================================================== */
@media (max-width: 900px) {
  .hero-title {
    font-size: 2.2rem;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .keyboard-wrapper {
    display: none; /* Auto-hide full keyboard visualizer on small screens */
  }
  .records-summary-card {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .nav-container {
    padding: 0 16px;
  }
  .nav-links {
    display: none; /* Mobile menu or compact pills */
  }
  .hero-title {
    font-size: 1.85rem;
  }
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .metric-card {
    padding: 12px 14px;
  }
  .metric-value {
    font-size: 1.6rem;
  }
  .typing-stage {
    padding: 20px 18px;
  }
  .words-container {
    font-size: 1.15rem;
    line-height: 1.9;
  }
  .controls-panel {
    flex-direction: column;
    align-items: stretch;
  }
  .segmented-control {
    width: 100%;
    justify-content: space-around;
  }
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}
