:root {
  --primary-color: #0284c7;
  --primary-hover: #0369a1;
  --bg-color: #f1f5f9;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --border-color: #cbd5e1;
}

*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  font-family: 'Kalpurush', 'Noto Sans Bengali', 'SolaimanLipi', 'Poppins', sans-serif;
}

body { 
  background-color: var(--bg-color); 
  padding: 15px; 
  display: flex; 
  justify-content: center; 
  align-items: flex-start;
  min-height: 100vh;
  color: var(--text-main);
}

body.typing-active {
  user-select: none;
  cursor: none !important;
}

body.typing-active *:not(#userInput):not(#passageText):not(#finishBtn):not(#customAlert):not(#customAlert *) {
  pointer-events: none !important;
  cursor: none !important;
}

body.typing-active #userInput {
  pointer-events: auto !important;
  cursor: text !important;
}

body.typing-active #passageText {
  pointer-events: auto !important;
  cursor: default !important;
}

body.typing-active #finishBtn {
  pointer-events: auto !important;
  cursor: pointer !important;
}

body.typing-active #customAlert {
  pointer-events: auto !important;
  cursor: pointer !important;
}

.container { 
  width: 100%; 
  max-width: 1200px; 
  background: var(--card-bg); 
  padding: 24px; 
  border-radius: 16px; 
  box-shadow: 0 10px 30px -5px rgba(0,0,0,0.08); 
}

.brand-header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
}

.brand-title {
  font-family: 'Poppins', 'Kalpurush', sans-serif;
  font-size: 30px;
  font-weight: 700;
  color: #0369a1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-subtitle {
  font-size: 15px;
  color: #475569;
  margin-top: 4px;
  font-weight: 600;
}

.lock-warning {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 20px;
  text-align: center;
  font-weight: 600;
  transition: all 0.3s ease;
}

.lock-warning.active-lock {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}

.top-bar { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 18px; 
  flex-wrap: wrap;
  gap: 12px;
}

.action-btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.timer-control-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.live-speed-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  padding: 6px 16px;
  border-radius: 8px;
  font-weight: 700;
  color: #166534;
  font-size: 16px;
}

.custom-select {
  background: #ffffff;
  border: 1.5px solid #94a3b8;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  outline: none;
  cursor: pointer;
  max-width: 100%;
}

.custom-select:focus { border-color: var(--primary-color); }
.timer-display { font-weight: 700; color: #2563eb; font-size: 17px; min-width: 95px; }

.lang-selection-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 15px;
  background: #f8fafc;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  margin-bottom: 15px;
  width: 100%;
}

.lang-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 45%; 
  min-width: 280px;
}

.select-label {
  font-weight: 600;
  font-size: 15px;
  color: #334155;
  white-space: nowrap;
}

.lang-btn-group select {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.btn { 
  border: none; 
  padding: 9px 18px; 
  border-radius: 8px; 
  cursor: pointer; 
  font-weight: 600; 
  font-size: 15px; 
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.add-text-btn { background-color: #0284c7; color: white; }
.manage-text-btn { background-color: #334155; color: white; }

.finish-btn { 
  background: #16a34a; 
  color: white; 
  font-size: 16px; 
  padding: 12px 26px; 
  margin-top: 14px; 
  border-radius: 8px; 
  width: 100%;
}

.reference-box { 
  border: 1.5px solid var(--border-color); 
  background: #fafbfc; 
  padding: 18px 20px; 
  border-radius: 10px; 
  margin-bottom: 15px; 
  max-height: 250px; 
  overflow-y: auto; 
  line-height: 2; 
  font-size: 19px;
  color: #1e293b;
  word-wrap: break-word;
  width: 100%;
  text-align: justify;
}

.typing-box textarea { 
  width: 100%; 
  height: 160px; 
  border: 1.5px solid var(--border-color); 
  border-radius: 10px; 
  padding: 14px 16px; 
  outline: none; 
  resize: vertical; 
  font-size: 19px; 
  line-height: 1.8; 
  text-align: justify;
}

.typing-box textarea:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.history-section { display: none; margin-top: 15px; }
.history-header { text-align: center; background: #e0e7ff; padding: 12px; border-radius: 30px; margin-bottom: 18px; font-weight: bold; color: #3730a3; font-size: 18px; }
.badge-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 15px; flex-wrap: wrap; }
.badge { padding: 6px 14px; border-radius: 20px; font-size: 14px; font-weight: bold; color: white; }
.pass-badge { background: #16a34a; }
.fail-badge { background: #dc2626; }

.delete-all-btn {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  color: #475569;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.delete-all-btn:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

.table-container { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: center; font-size: 15px; min-width: 750px; }
th { background: #f8fafc; padding: 12px; color: #475569; border-bottom: 2px solid #e2e8f0; }
td { padding: 12px; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }

.lang-badge { padding: 4px 10px; border-radius: 12px; font-size: 13px; font-weight: 600; color: white; }
.lang-bn { background: #0284c7; }
.lang-en { background: #9333ea; }

.action-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 14px;
}
.view-icon-btn { background: #2563eb; }
.del-icon-btn { background: #ef4444; }

.status-pill {
  padding: 5px 12px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 13px;
  color: white;
}

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.55); justify-content: center; align-items: center; z-index: 1000; padding: 15px; }
.modal-content { background: white; width: 100%; max-width: 850px; border-radius: 14px; padding: 24px; max-height: 90vh; overflow-y: auto; position: relative; }
.close-modal { position: absolute; top: 14px; right: 20px; font-size: 24px; cursor: pointer; border: none; background: none; color: #64748b; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; color: #334155; }
.input-field { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; outline: none; font-size: 16px; }
.custom-text-area { width: 100%; height: 140px; padding: 12px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 18px; outline: none; line-height: 1.6; resize: vertical; text-align: justify; }

.passage-item-list { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; max-height: 350px; overflow-y: auto; }
.passage-item { display: flex; justify-content: space-between; align-items: center; background: #f8fafc; border: 1px solid var(--border-color); padding: 12px 16px; border-radius: 8px; }
.action-btn-group-item { display: flex; gap: 6px; align-items: center; }
.edit-btn { background: #d97706; color: white; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.del-btn { background: #dc2626; color: white; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }

.result-modal-header { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: 20px; }
.result-modal-title { font-size: 22px; font-weight: 700; color: #0f172a; }
.brand-badge { background: #16a34a; color: white; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.result-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 15px; margin-bottom: 20px; }
.res-card { background: #ffffff; border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.res-card.green-card { border: 1.5px solid #22c55e; }
.res-card.blue-card { border: 1.5px solid #3b82f6; }
.res-card.red-card { border: 1.5px solid #ef4444; }
.res-card-title { font-weight: 700; font-size: 15px; color: #1e293b; padding-bottom: 6px; border-bottom: 1px dashed #cbd5e1; margin-bottom: 4px; }
.res-card-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #334155; font-weight: 500; }
.banner-bar { background: #0f172a; color: white; padding: 12px 18px; border-radius: 8px; display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 600; margin-bottom: 20px; }
.banner-status { padding: 3px 12px; border-radius: 4px; font-size: 14px; font-weight: 700; color: white; }
.banner-status.pass { background: #16a34a; }
.banner-status.fail { background: #dc2626; }
.analysis-section-title { font-weight: 700; color: #3730a3; font-size: 16px; margin-bottom: 12px; }
.section-box { border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; margin-bottom: 16px; background: #ffffff; }
.section-box-title { font-weight: 600; color: #334155; font-size: 15px; margin-bottom: 10px; }
.typed-text-display { line-height: 1.8; font-size: 17px; word-wrap: break-word; text-align: justify; }

.wrong-word-highlight { 
  color: #000000; 
  background: none !important;
  text-decoration: line-through; 
  text-decoration-color: #ef4444; 
  text-decoration-thickness: 2.5px;
  padding: 0 2px; 
  display: inline-block; 
  font-weight: 600; 
}
.correct-word-highlight { color: #0f172a; margin: 0 2px; display: inline-block; }
.passage-text-display { line-height: 1.9; font-size: 17px; color: #334155; word-wrap: break-word; text-align: justify; }

.ai-btn {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: white;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  transition: all 0.2s ease;
}
.ai-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}
.ai-analysis-box {
  margin-top: 15px;
  display: none;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 14px;
}
.ai-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}
.ai-table th {
  background: #e2e8f0;
  color: #1e293b;
  padding: 8px 10px;
  text-align: left;
}
.ai-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

@media (max-width: 820px) {
  .lang-btn-group { flex: 1 1 100%; }
  .top-bar { flex-direction: column; align-items: stretch; }
  .action-btn-group { justify-content: space-between; }
  .timer-control-box { justify-content: space-between; }
}