/* Global reset & base */
* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: #f8f9fa;
  color: #333;
  margin: 0;
  line-height: 1.6;
}

/* Header */
header {
  text-align: center;
  background: #007bff;
  color: #fff;
  padding: 2rem 1rem 1.5rem;
}

header h1 {
  margin: 0;
  font-size: 2.2rem;
}

header p.intro {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  opacity: 0.95;
}

/* Dark mode toggle button */
.theme-toggle {
  margin-top: 1rem;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Layout */
main {
  max-width: 1200px;
  margin: auto;
  padding: 2rem 1rem;
}

section {
  background: #fff;
  padding: 2rem;
  margin-bottom: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.08);
}

.section-title {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.7rem;
  color: #007bff;
  position: relative;
}

.section-title::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background-color: #007bff;
  border-radius: 2px;
  opacity: 0.8;
}

/* Grid layout */
/* .calc-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
  align-items: flex-start;
}

.calc-left,
.calc-right {
  padding: 0;
} */

.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); /* left wider than right */
  gap: 1.5rem;
  align-items: stretch;
}

/* Make both columns behave like vertical stacks */
.calc-left,
.calc-right {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}


/* Controls */
.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.control-group {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
}

.control-group.full-width {
  flex-basis: 100%;
}

.control-group label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #0056b3;
}

.control-group select {
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #ced4da;
  font-size: 1rem;
}

.control-group select:focus {
  border-color: #007bff;
  outline: none;
}

.help-text {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.25rem;
}

/* Sample text and typing area */
/* .sample-wrapper {
  background: #f8f9ff;
  border-radius: 8px;
  border: 1px solid #e1e8ef;
  padding: 1rem;
  margin-bottom: 1rem;
} */
.sample-wrapper {
  background: #f8f9ff;
  border-radius: 8px;
  border: 1px solid #e1e8ef;
  padding: 1rem;
  /* NEW: help visually balance height with right column */
  min-height: 140px;
}

.sample-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #0056b3;
  margin-bottom: 0.5rem;
}

.sample-text {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.6;
  color: #333;
}

.typing-area {
  margin-top: 1rem;
}

/* .typing-area label {
  display: block;
  font-weight: 600;
  color: #0056b3;
  margin-bottom: 0.25rem;
} */

.typing-area {
  margin-top: 0.5rem;
  background: #f8f9ff;
  border-radius: 8px;
  border: 1px solid #e1e8ef;
  padding: 1rem;
}

/* #typingInput {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #ced4da;
  padding: 0.75rem;
  font-size: 1rem;
  resize: vertical;
} */

#typingInput {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #ced4da;
  padding: 0.75rem;
  font-size: 1rem;
  resize: vertical;
  min-height: 170px; /* NEW: taller typing area */
}

#typingInput:focus {
  border-color: #007bff;
  outline: none;
}

/* Highlight mistakes toggle + preview */
.highlight-toggle {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #555;
}

.highlight-toggle input {
  width: 16px;
  height: 16px;
}

.highlight-preview {
  display: none;
  margin-top: 0.5rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px dashed #e1e8ef;
  background: #fdfdfd;
  font-family: "Courier New", monospace;
  font-size: 0.95rem;
  min-height: 60px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.highlight-preview span.correct {
  color: #222;
}

.highlight-preview span.wrong {
  background: #ffe5e5;
  color: #b00020;
}

.highlight-preview span.pending {
  color: #bbbbbb;
}

/* Buttons */
.btn-primary,
.btn-secondary {
  padding: 0.7rem 1.3rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  margin-right: 0.5rem;
  transition: 0.15s;
}

.btn-primary {
  background: #007bff;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #0056b3;
  transform: translateY(-2px);
}

.btn-secondary {
  background: #6c757d;
  color: #fff;
}

.btn-secondary:hover:not(:disabled) {
  background: #545b62;
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

/* Results / Stats */
.result-card {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 0.9rem;
  border: 1px solid #e1e8ef;
  margin-bottom: 0.9rem;
}

.result-card .label {
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  font-weight: 600;
  color: #0056b3;
}

.result-card .value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #222;
  word-break: break-word;
}

.best-score-card .value,
.streak-card .value {
  font-size: 1rem;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.4rem;
}

.progress-fill {
  height: 100%;
  width: 100%;
  background: #007bff;
  transition: width 0.2s linear;
}

/* Notes */
.note-box {
  text-align: center;
  margin-top: 1rem;
  padding: 1rem 1.5rem;
  border: 2px solid #007bff;
  border-radius: 8px;
  background: #e9f5ff;
  font-weight: 500;
  color: #0056b3;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.08);
}

.note-box.small {
  font-size: 0.9rem;
  padding: 0.8rem 1rem;
}

.note-inline {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #0056b3;
}

/* Alignment row */
.align-middle {
  display: flex;
  align-items: center;
}

/* Steps section */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.step {
  background: #ffffff;
  border: 1px solid #e1e8ef;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}

.step-number {
  width: 50px;
  height: 50px;
  background: linear-gradient(145deg, #007bff, #0056b3);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  border-radius: 50%;
}

/* Benefits section */
.benefits-grid ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.benefits-grid li {
  background: #f8f9fa;
  padding: 1rem;
  border-left: 4px solid #007bff;
  border-radius: 6px;
  font-size: 1rem;
}

/* FAQ styles */
#faq {
  margin-top: 1rem;
}

.faq-question {
  width: 100%;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 1rem;
  font-weight: bold;
  text-align: left;
  cursor: pointer;
  color: #007bff;
  margin-bottom: 0.5rem;
}

.faq-answer {
  display: none;
  padding: 1rem;
  border-left: 3px solid #007bff;
  background: #fff;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.faq-item.active .faq-answer {
  display: block;
}

/* Footer */
footer {
  background: #f1f1f1;
  text-align: center;
  padding: 2rem 1rem;
  color: #666;
}

footer a {
  color: #007bff;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Dark mode overrides */
body.dark-mode {
  background: #0b1020;
  color: #f3f4f6;
}

body.dark-mode header {
  background: #0050c8;
}

body.dark-mode .theme-toggle {
  border-color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.35);
}

body.dark-mode section {
  background: #151b2d;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
}

body.dark-mode .section-title {
  color: #90caf9;
}

body.dark-mode .section-title::after {
  background: #90caf9;
}

body.dark-mode .sample-wrapper {
  background: #111827;
  border-color: #24324f;
}

body.dark-mode .sample-text {
  color: #f1f5f9;
}

body.dark-mode #typingInput {
  background: #0f172a;
  color: #e5e7eb;
  border-color: #334155;
}

body.dark-mode .highlight-preview {
  background: #020617;
  border-color: #1e293b;
}

body.dark-mode .highlight-preview span.pending {
  color: #6b7280;
}

body.dark-mode .result-card {
  background: #111827;
  border-color: #1f2937;
}

body.dark-mode .result-card .label {
  color: #bfdbfe;
}

body.dark-mode .result-card .value {
  color: #e5e7eb;
}

body.dark-mode .progress-bar {
  background: #1f2937;
}

body.dark-mode .progress-fill {
  background: #38bdf8;
}

body.dark-mode .benefits-grid li {
  background: #111827;
  border-left-color: #90caf9;
}

body.dark-mode .note-box {
  background: #0f172a;
  border-color: #90caf9;
  color: #e0f2fe;
}

body.dark-mode .note-inline {
  color: #bfdbfe;
}

body.dark-mode .faq-question {
  background: #111827;
  border-color: #1f2937;
  color: #90caf9;
}

body.dark-mode .faq-answer {
  background: #0f172a;
  border-left-color: #90caf9;
  color: #e5e7eb;
}

body.dark-mode footer {
  background: #020617;
  color: #9ca3af;
}

body.dark-mode footer a {
  color: #93c5fd;
}

/* Buttons in dark mode */
body.dark-mode .btn-primary {
  background: #0ea5e9;
}

body.dark-mode .btn-primary:hover:not(:disabled) {
  background: #0284c7;
}

body.dark-mode .btn-secondary {
  background: #4b5563;
}

body.dark-mode .btn-secondary:hover:not(:disabled) {
  background: #374151;
}

/* Responsive tweaks */
@media (max-width: 960px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 600px) {
  section {
    padding: 1.5rem 1.2rem;
  }

  .btn-primary,
  .btn-secondary {
    margin-bottom: 0.5rem;
  }
}
@media (max-width: 960px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }
}
