/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Tokens ── */
:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --correct: #16a34a;
  --wrong: #dc2626;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
}

/* ── Base ── */
html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
}

/* ── Picker bar ── */
#picker-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  flex-shrink: 0;
  z-index: 100;
}

#picker-bar .pickers-row {
  margin-bottom: 0;
}

/* ── Screens ── */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.screen.active {
  display: flex;
}

/* ── App header ── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.app-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.back-btn:hover {
  background: var(--bg);
}

/* ── List picker (custom dropdown) ── */
.pickers-row {
  display: flex;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto 20px;
}

.list-picker {
  position: relative;
  flex: 1;
  min-width: 0;
}

.list-picker-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.15s;
}

.list-picker-btn:hover {
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.15);
}

.list-picker-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.list-picker-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
}

.list-picker-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#unit-picker {
  flex: 2;
}

.list-picker-chevron {
  width: 20px;
  height: 20px;
  color: var(--primary);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.list-picker.open .list-picker-chevron {
  transform: rotate(180deg);
}

.list-picker-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 200;
  overflow: hidden;
}

#unit-picker-dropdown {
  right: auto;
  min-width: 240px;
}

.list-picker-group {
  padding: 8px 0 4px;
}

.list-picker-group + .list-picker-group {
  border-top: 1px solid var(--border);
}

.list-picker-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 4px 16px 6px;
  display: block;
}

.list-picker-option {
  width: 100%;
  display: block;
  padding: 10px 16px;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}

.list-picker-option:hover {
  background: var(--bg);
}

.list-picker-option.current {
  color: var(--primary);
  font-weight: 700;
}

/* ── Quiz header ── */
.quiz-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.quiz-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
}

.quiz-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.quiz-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.quiz-nav-btn:not(:disabled):hover {
  background: var(--bg);
  color: var(--text);
}

.quiz-nav-btn:not(:disabled):active {
  background: var(--border);
}

.quiz-header-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  line-height: 1;
}

.close-btn:hover {
  color: var(--wrong);
  background: #fef2f2;
}

.progress-track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-count {
  font-size: 0.82rem;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
}

.quiz-settings {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.quiz-settings-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.quiz-settings-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s;
}

.quiz-settings-select:hover {
  border-color: var(--primary);
}

.quiz-settings-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Screen body ── */
.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}

/* center on wide screens */
.screen-body > * {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Home: list cards ── */
.subject-section {
  margin-bottom: 28px;
}

.subject-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
}

.list-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: block;
  margin-bottom: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.list-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(79, 70, 229, 0.1);
}

.list-card-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.list-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.list-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.list-progress-bar {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.list-progress-fill {
  height: 100%;
  background: var(--correct);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ── Tab bar ── */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.tab-btn {
  flex: 1;
  padding: 8px 0;
  background: none;
  border: none;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ── Settings bar ── */
.settings-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border-radius: 10px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.settings-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.settings-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s;
}

.settings-select:hover {
  border-color: var(--primary);
}

.settings-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ── Mode selection ── */
.section-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 14px;
  display: block;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.mode-grid--three {
  grid-template-columns: 1fr 1fr 1fr;
}

.mode-grid--one {
  grid-template-columns: 1fr;
}

.mode-grid--two {
  grid-template-columns: 1fr 1fr;
}

.mcq-choice-btn.mcq-choice-selected {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.08);
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  display: block;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.mode-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(79, 70, 229, 0.1);
}

.mode-card--wide {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: left;
}

.mode-card--wide .mode-icon {
  margin-bottom: 0;
}

.mode-icon {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 5px;
}

.mode-name {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.mode-desc {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Secondary tiles (Browse / Stats) ── */
.secondary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.secondary-tile {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.secondary-tile:hover {
  border-color: var(--primary);
}

.secondary-tile.active {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.06);
}

.secondary-tile-icon {
  font-size: 1.1rem;
}

.secondary-tile-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.secondary-tile.active .secondary-tile-name {
  color: var(--primary);
}

/* ── Progress export / import ── */
.progress-io {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.progress-io-btn {
  background: none;
  border: none;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: inherit;
}

.progress-io-btn:hover { color: var(--primary); }

.progress-io-divider {
  color: var(--border);
  font-size: 0.9rem;
  user-select: none;
}

/* ── GitHub sync panel ── */
.github-sync-btn--ok  { color: var(--correct) !important; }
.github-sync-btn--err { color: var(--wrong)   !important; }

.github-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.github-panel-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.github-panel-hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 10px;
}

.github-panel-hint code {
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.75rem;
}

.github-panel-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.github-token-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: monospace;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

.github-token-input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-small {
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.btn-small:hover { background: var(--primary-dark); }

.github-token-error {
  font-size: 0.78rem;
  color: var(--wrong);
  margin-bottom: 6px;
}

.github-disconnect-btn {
  color: var(--wrong) !important;
  margin-top: 4px;
}

/* ── Progress stats ── */
.progress-stats {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.stat-num {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 3px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

/* ── Quiz modes ── */
.quiz-mode {
  height: 100%;
}

.quiz-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
  max-width: 480px;
  margin: 0 auto;
}

.direction-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(79, 70, 229, 0.08);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Diagram image in flashcard ── */
.fc-diagram-img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 10px;
}

/* ── Flashcard ── */
.fc-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
  padding: 28px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}

.fc-card:active { border-color: var(--primary); }

.fc-term {
  font-size: 1.7rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}

.fc-card--question .fc-term {
  font-size: 1.1rem;
  font-weight: 600;
  text-align: left;
}

.fc-definition {
  width: 100%;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  animation: fcReveal 0.2s ease;
}

.fc-definition.hidden { display: none; }

@keyframes fcReveal {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fc-def-text {
  font-size: 1.05rem;
  line-height: 1.5;
  text-align: center;
  color: var(--text);
  display: block;
}

.hint-text {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 20px;
}

.answer-btns {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn-wrong {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: #fee2e2;
  color: var(--wrong);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-wrong:hover {
  background: #fecaca;
}

.btn-correct {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: #dcfce7;
  color: var(--correct);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-correct:hover {
  background: #bbf7d0;
}

/* ── Type it ── */
.word-display {
  font-size: 2.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 28px;
  line-height: 1.2;
}

.type-area {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 16px;
}

.type-area input {
  flex: 1;
  padding: 13px 15px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  background: var(--surface);
  color: var(--text);
}

.type-area input:focus {
  border-color: var(--primary);
}

.type-area input:disabled {
  background: var(--bg);
  color: var(--muted);
}

.btn-check {
  padding: 13px 18px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-check:hover {
  background: var(--primary-dark);
}

.feedback {
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--radius);
  width: 100%;
  text-align: center;
  margin-bottom: 14px;
}

.feedback-correct {
  background: #dcfce7;
  color: var(--correct);
}

.feedback-wrong {
  background: #fee2e2;
  color: var(--wrong);
}

.btn-next {
  padding: 13px 36px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-next:hover {
  background: var(--primary-dark);
}

/* ── Multiple choice ── */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-bottom: 18px;
}

.choice-btn {
  padding: 22px 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.3;
  word-break: break-word;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.04);
}

.choice-btn.choice-correct {
  border-color: var(--correct);
  background: #dcfce7;
  color: var(--correct);
}

.choice-btn.choice-wrong {
  border-color: var(--wrong);
  background: #fee2e2;
  color: var(--wrong);
}

.choice-btn:disabled {
  cursor: default;
}

/* ── Results ── */
.results-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 0 28px;
}

.score-big {
  font-size: 4.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.score-sub {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 6px;
}

.results-details {
  margin-bottom: 24px;
}

.results-details h3 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}

.missed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.missed-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
}

.missed-prompt {
  font-weight: 600;
}

.missed-arrow {
  color: var(--muted);
}

.missed-answer {
  color: var(--correct);
  font-weight: 500;
}

.all-correct {
  text-align: center;
  color: var(--correct);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 16px 0 24px;
}

.results-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 24px;
}

.btn-primary {
  padding: 13px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  padding: 13px 24px;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Stats mode ── */
.stats-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.sort-btn {
  padding: 7px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  font-family: inherit;
  color: var(--text);
}

.sort-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.sort-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.col-num {
  text-align: center;
}

.sortable-col {
  cursor: pointer;
  user-select: none;
}

.sortable-col:hover {
  color: var(--primary);
}

.sort-indicator {
  color: var(--muted);
  font-size: 0.8em;
}

.sort-asc  .sort-indicator { color: var(--primary); }
.sort-desc .sort-indicator { color: var(--primary); }

.stats-num {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats-acc {
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.acc-good { color: var(--correct); }
.acc-ok   { color: #d97706; }
.acc-bad  { color: var(--wrong); }

.stats-unseen td {
  opacity: 0.35;
}

/* ── Browse mode ── */
.mode-card--browse {
  border-style: dashed;
  margin-top: 4px;
}

.word-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  max-width: 560px;
  margin: 0 auto;
}

.word-table th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: var(--bg);
}

.word-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.4;
}

.word-table td:first-child {
  font-weight: 600;
}

.word-table tbody tr:last-child td {
  border-bottom: none;
}

.word-table tbody tr:hover {
  background: rgba(79, 70, 229, 0.03);
}

/* ── Match mode ── */
.match-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.match-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-bottom: 20px;
}

.match-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.match-item {
  width: 100%;
  min-height: 58px;
  padding: 10px 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.3;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-item-label {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  word-break: break-word;
}

.match-item:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.04);
}

.match-item.selected {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

.match-item.matched {
  border-color: var(--correct);
  background: #dcfce7;
  color: var(--correct);
  cursor: default;
}

.match-item.wrong {
  border-color: var(--wrong);
  background: #fee2e2;
  color: var(--wrong);
}

.match-complete {
  padding: 16px 0 24px;
  display: flex;
  justify-content: center;
}

/* ── Update banner ── */
.update-banner {
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  font-size: 0.9rem;
  color: #78350f;
}

.update-banner-msg {
  flex: 1;
}

.update-banner-reload {
  background: #92400e;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.update-banner-reload:hover {
  background: #78350f;
}

.update-banner-dismiss {
  background: none;
  border: none;
  color: #78350f;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  line-height: 1;
  opacity: 0.7;
}

.update-banner-dismiss:hover {
  opacity: 1;
}

/* ── Install tip ── */
.install-tip {
  position: relative;
  background: rgba(79, 70, 229, 0.06);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: var(--radius);
  padding: 14px 40px 14px 16px;
  margin-bottom: 20px;
}

.install-tip-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 2px 6px;
  line-height: 1;
}

.install-tip-dismiss:hover {
  color: var(--text);
}

.install-tip-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 6px;
}

.install-tip-text {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.6;
}

/* ── Utilities ── */
.hidden {
  display: none !important;
}

.muted-text {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: 0.95rem;
}

/* ── Reference chart button & overlay ── */
.ref-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
  white-space: nowrap;
}
.ref-btn:hover { background: var(--border); color: var(--text); }

.ref-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ref-overlay.hidden { display: none; }

.ref-overlay-inner {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ref-overlay-close {
  position: absolute;
  top: -12px;
  right: -12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 201;
}

.ref-img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 8px;
  object-fit: contain;
}

/* ── Terms browse (quiz lists) ── */
.terms-term {
  font-weight: 600;
  color: var(--text);
  width: 35%;
  vertical-align: top;
}

.terms-def {
  color: var(--muted);
  line-height: 1.5;
  vertical-align: top;
}

/* ── MC Quiz mode ── */
.mcq-inner {
  gap: 16px;
}

.mcq-question {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  padding: 4px 0 8px;
}

.mcq-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.mcq-choice-btn {
  padding: 16px 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text);
  line-height: 1.4;
}

.mcq-choice-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.04);
}

.mcq-choice-btn.choice-correct {
  border-color: var(--correct);
  background: #dcfce7;
  color: var(--correct);
}

.mcq-choice-btn.choice-wrong {
  border-color: var(--wrong);
  background: #fee2e2;
  color: var(--wrong);
}

.mcq-choice-btn:disabled {
  cursor: default;
}

.mcq-feedback {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.mcq-feedback-badge {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.mcq-badge--correct { color: var(--correct); }
.mcq-badge--wrong   { color: var(--wrong); }

.mcq-explanation {
  color: var(--muted);
}

/* ── MC Quiz results ── */
.score-pct {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 4px;
}

.score-grade-a { color: var(--correct); }
.score-grade-b { color: #16a34a; }
.score-grade-c { color: #ca8a04; }
.score-grade-d { color: #ea580c; }
.score-grade-f { color: var(--wrong); }

.mcq-missed-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}

.mcq-missed-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.mcq-item--correct {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.mcq-missed-q {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.mcq-missed-chosen {
  color: var(--muted);
  margin-bottom: 4px;
}

.mcq-chosen-text {
  color: var(--wrong);
  font-weight: 500;
}

.mcq-missed-why-wrong {
  color: var(--muted);
  font-style: italic;
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 2px solid var(--wrong);
}

.mcq-missed-correct {
  color: var(--text);
  font-weight: 500;
  margin-bottom: 4px;
}

.mcq-correct-text {
  color: var(--correct);
  font-weight: 600;
}

.mcq-missed-why-correct {
  color: var(--muted);
  font-style: italic;
  padding-left: 8px;
  border-left: 2px solid var(--correct);
}

/* ── Translate mode ── */
.translate-sentence {
  font-size: 1.2rem;
  line-height: 1.6;
  text-align: center;
  margin-bottom: 20px;
}

.translate-type-area {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}

.translate-input {
  width: 100%;
  padding: 13px 15px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  box-sizing: border-box;
}

.translate-input:focus {
  border-color: var(--primary);
}

.translate-input:disabled {
  background: var(--bg);
  color: var(--muted);
}

.translate-feedback {
  width: 100%;
  margin-top: 16px;
}

.translate-correct-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.translate-correct-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--correct);
  padding: 12px 16px;
  background: #dcfce7;
  border-radius: var(--radius);
  margin-bottom: 4px;
}

/* ── Translate results ── */
.translate-missed-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.translate-missed-item {
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 3px solid var(--wrong);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.translate-missed-prompt {
  font-weight: 600;
  color: var(--text);
}

.translate-missed-yours {
  font-size: 0.9rem;
  color: var(--muted);
}

.translate-yours-text {
  color: var(--wrong);
  font-style: italic;
}

.translate-missed-correct {
  font-size: 0.9rem;
  color: var(--text);
}

.translate-correct-ans {
  color: var(--correct);
  font-weight: 600;
}

/* ── Concept breakdown ── */
.concept-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.concept-tag {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
}

.concept-name {
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
  font-size: 0.95rem;
}

.concept-count {
  font-size: 0.85rem;
  color: var(--wrong);
  font-weight: 600;
}
