* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f7fa;
  color: #1a1a2e;
  line-height: 1.6;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.navbar {
  background: #1a1a2e;
  padding: 0.75rem 0;
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  color: #e94560;
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
}

.nav-links a {
  color: #fff;
  text-decoration: none;
  margin-left: 1.25rem;
  font-size: 0.9rem;
  opacity: 0.85;
}

.nav-links a:hover { opacity: 1; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.flash.error { background: #ffe0e0; color: #c0392b; border: 1px solid #f5c6cb; }
.flash.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

h1 { font-size: 1.75rem; margin-bottom: 1rem; }
h2 { font-size: 1.35rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }

.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.auth-form {
  max-width: 400px;
  margin: 3rem auto;
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.auth-form label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.auth-form input {
  width: 100%;
  padding: 0.6rem;
  margin-bottom: 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.auth-form button {
  width: 100%;
  padding: 0.7rem;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}

.auth-form button:hover { background: #d63850; }
.auth-form p { text-align: center; margin-top: 1rem; font-size: 0.9rem; }

.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: #e94560;
  color: #fff;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn:hover { background: #d63850; }
.btn-secondary { background: #6c757d; }
.btn-secondary:hover { background: #5a6268; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }

.score-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
}

.score-high { background: #d4edda; color: #155724; }
.score-mid { background: #fff3cd; color: #856404; }
.score-low { background: #ffe0e0; color: #c0392b; }

.passage-text {
  background: #f8f9fa;
  padding: 1.25rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

.question-item {
  padding: 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

.question-item label {
  display: block;
  margin: 0.35rem 0;
  font-size: 0.9rem;
}

.question-item input[type="text"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
}

.explanation-box {
  background: #f0f4ff;
  padding: 1rem;
  border-radius: 6px;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  border-left: 3px solid #e94560;
}

.timer {
  position: fixed;
  top: 0.75rem;
  right: 1rem;
  background: #1a1a2e;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 1.1rem;
  z-index: 100;
}

.timer.warning { background: #e94560; }

.chat-box {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.chat-msg {
  margin-bottom: 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.chat-msg.user { background: #e94560; color: #fff; text-align: right; }
.chat-msg.assistant { background: #f0f4ff; }

.chat-input {
  display: flex;
  gap: 0.5rem;
}

.chat-input input {
  flex: 1;
  padding: 0.6rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
}

.skill-card {
  text-align: center;
  padding: 1.5rem;
}

.skill-score {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.5rem 0;
}

.difficulty-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.difficulty-easy { background: #d4edda; color: #155724; }
.difficulty-medium { background: #fff3cd; color: #856404; }
.difficulty-hard { background: #ffe0e0; color: #c0392b; }

.lesson-section {
  margin-bottom: 1.5rem;
}

.pattern-feedback {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 1.25rem;
  margin-top: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

.streak-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.session-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

.session-row:last-child { border-bottom: none; }

/* Question input styles */
.tfng-options {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.radio-label {
  display: inline-flex !important;
  align-items: center;
  cursor: pointer;
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-btn {
  display: inline-block;
  padding: 0.4rem 1rem;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.15s;
}

.radio-label input[type="radio"]:checked + .radio-btn {
  border-color: #e94560;
  background: #e94560;
  color: #fff;
}

.radio-label:hover .radio-btn {
  border-color: #e94560;
}

.inline-question {
  font-size: 0.95rem;
  line-height: 2.2;
  margin-top: 0.5rem;
}

.inline-input {
  display: inline-block;
  width: 90px;
  padding: 0.1rem 0.25rem;
  border: none;
  border-bottom: 2px solid #e94560;
  background: transparent;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  vertical-align: baseline;
}

.inline-input:focus {
  border-bottom-color: #1a1a2e;
}

.text-input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.text-input:focus {
  border-color: #e94560;
  outline: none;
}

.answer-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}

.answer-label {
  font-size: 0.85rem;
  color: #666;
  font-weight: 600;
}

.answer-value {
  font-weight: 700;
  font-size: 0.95rem;
}

.answer-correct { color: #28a745; }
.answer-wrong { color: #dc3545; }

.word-limit-hint {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 1rem;
  font-style: italic;
}

.focus-link {
  color: #e94560;
  text-decoration: none;
  border-bottom: 2px solid #e94560;
  padding-bottom: 1px;
}

.focus-link:hover {
  color: #d63850;
  border-bottom-color: #d63850;
}

/* Word lookup panel */
#word-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 340px;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  z-index: 1000;
  transition: right 0.25s ease;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e0e0e0;
}

#word-panel.open { right: 0; }

.word-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #eee;
  background: #1a1a2e;
  color: #fff;
}

.word-panel-title {
  font-weight: 700;
  font-size: 1rem;
}

.word-panel-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.word-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.word-panel-empty {
  color: #888;
  text-align: center;
  font-size: 0.9rem;
  margin-top: 2rem;
}

.word-entry {
  padding: 0.75rem;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: #fafafa;
}

.word-entry.highlighted {
  border-color: #e94560;
  background: #fff0f3;
}

.word-entry-word {
  font-weight: 700;
  font-size: 1rem;
  color: #1a1a2e;
  margin-bottom: 0.25rem;
  text-transform: lowercase;
}

.word-entry-def {
  font-size: 0.88rem;
  color: #555;
  line-height: 1.5;
}

.multi-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.multi-hint {
  width: 100%;
  font-size: 0.8rem;
  color: #888;
  font-style: italic;
  margin-top: 0.25rem;
}

.multi-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.multi-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.chip-correct {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.chip-missing {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.chip-extra {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
}

/* Diagnostic results */
.dashboard-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

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

.dashboard-header nav a {
  margin-left: 1rem;
  text-decoration: none;
  color: #e94560;
  font-weight: 600;
  font-size: 0.9rem;
}

.score-summary {
  text-align: center;
  margin-bottom: 2rem;
}

.score-circle {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 6px solid #e0e0e0;
}

.score-pass { border-color: #28a745; }
.score-partial { border-color: #ffc107; }
.score-fail { border-color: #dc3545; }

.score-value {
  font-size: 2.5rem;
  font-weight: 800;
}

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

.results-list {
  margin-bottom: 2rem;
}

.result-item {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-left: 4px solid #e0e0e0;
}

.result-correct { border-left-color: #28a745; }
.result-incorrect { border-left-color: #dc3545; }

.result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.result-status {
  font-size: 1.25rem;
  font-weight: 800;
}

.result-correct .result-status { color: #28a745; }
.result-incorrect .result-status { color: #dc3545; }

.result-type {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 0.5px;
}

.result-question {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.result-answers {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.result-user { color: #dc3545; }
.result-correct-ans { color: #28a745; }

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
