@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

/* Els colors de text estan mesurats, no triats a ull: cadascun arriba a 4,5:1
   sobre TOTS els fons on l'app el fa servir de veritat (WCAG 2.1 AA), amb
   marge. Es comprova amb `node test/f39.contrast.js`, que ho mesura al
   navegador. Abans d'això, quatre no hi arribaven — l'avís de «no hi ha veu»
   es quedava a 3,07:1, que és el més important que diu l'app.
   Si en canvies cap, torna a passar la mesura. */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --text: #0f172a;
  --text-muted: #5b6675;
  --success: #15803d;
  --success-light: #f0fdf4;
  --error: #b91c1c;
  --error-light: #fef2f2;
  --warning: #b45309;
  --warning-light: #fffbeb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────── */
.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.app-header .logo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.app-main {
  flex: 1;
  padding: 32px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* ── Avatar + dropdown ───────────────────────── */
.avatar-wrap { position: relative; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.8125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: opacity .15s;
}
.avatar:hover { opacity: 0.85; }

.avatar-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  z-index: 100;
  overflow: hidden;
}
.avatar-dropdown.open { display: block; }

.avatar-email {
  padding: 12px 16px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  transition: background .1s;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item-danger { color: var(--error); }
.dropdown-item-danger:hover { background: var(--error-light); }

/* ── Card ────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 24px; }
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text); }

/* ── Login ───────────────────────────────────── */
.login-box { width: 100%; max-width: 400px; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--primary); letter-spacing: -0.03em; }
.login-logo p { font-size: 0.875rem; color: var(--text-muted); margin-top: 4px; }

/* ── Forms ───────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-input.textarea { resize: vertical; min-height: 160px; line-height: 1.7; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ── Alert ───────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-error { background: var(--error-light); color: var(--error); border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }

/* ── Level selector ──────────────────────────── */
.level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.level-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  text-align: center;
  user-select: none;
}
.level-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.level-card.active { border-color: var(--primary); background: var(--primary-light); }
.level-card .level-icon { font-size: 1.75rem; margin-bottom: 8px; }
.level-card .level-name { font-weight: 600; font-size: 0.875rem; }
.level-card .level-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ── Text list ───────────────────────────────── */
.text-list { display: flex; flex-direction: column; gap: 8px; }
.text-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--surface);
}
.text-item:hover { border-color: var(--primary); background: var(--primary-light); }
.text-item .text-title { font-weight: 500; font-size: 0.9375rem; }
.text-item .text-meta { font-size: 0.8125rem; color: var(--text-muted); margin-top: 2px; }
.text-item .text-words { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; margin-left: 12px; }

/* ── Mode toggle ─────────────────────────────── */
.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  width: fit-content;
}
.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 7px;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.mode-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ── Paper info ──────────────────────────────── */
.paper-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  color: var(--primary);
}

/* ── Photo upload ────────────────────────────── */
.photo-upload-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9375rem;
  color: var(--text-muted);
  transition: border-color .15s, color .15s;
  background: var(--bg);
}
.photo-upload-label:hover { border-color: var(--primary); color: var(--primary); }

/* ── Dictation view ──────────────────────────── */
.dictation-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.progress-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width .3s ease;
  width: 0%;
}
.phrase-indicator { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 12px; }

.speaking-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
}
.speaking-badge .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.8); } }

.pause-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--warning-light);
  color: var(--warning);
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
}

/* ── Scale labels ────────────────────────────── */
.scale-label { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.scale-sub { font-size: 1rem; color: var(--text-muted); margin-top: 4px; }

.scale-excellent { color: var(--success); }
.scale-great     { color: var(--success); }
.scale-good      { color: var(--primary); }
.scale-ok        { color: var(--warning); }
.scale-keep      { color: var(--error); }

/* Badge compact per a historial */
.scale-badge {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.scale-badge.scale-excellent, .scale-badge.scale-great { background: var(--success-light); color: var(--success); }
.scale-badge.scale-good { background: var(--primary-light); color: var(--primary); }
.scale-badge.scale-ok { background: var(--warning-light); color: var(--warning); }
.scale-badge.scale-keep { background: var(--error-light); color: var(--error); }

/* ── Score display ───────────────────────────── */
.score-display {
  text-align: center;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

/* ── Correction ──────────────────────────────── */
.correction-body { padding: 24px; }
.original-marked {
  font-size: 1.0625rem;
  line-height: 2;
  margin-bottom: 24px;
  padding: 20px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.word-error {
  background: var(--error-light);
  color: var(--error);
  border-bottom: 2px solid var(--error);
  border-radius: 2px;
  padding: 0 2px;
  cursor: pointer;
}
.word-ok { color: inherit; }

/* F32 — els dos textos enfrontats */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.compare-grid .original-marked { margin-bottom: 0; height: 100%; }
.compare-label {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px;
}
@media (max-width: 720px) { .compare-grid { grid-template-columns: 1fr; } }
.word-gap {
  background: var(--error-light);
  color: var(--error);
  border-bottom: 2px dashed var(--error);
  border-radius: 2px;
  padding: 0 6px;
  cursor: pointer;
}

.errors-list { margin-bottom: 24px; }
.errors-list h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.error-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.error-item:last-child { border-bottom: none; }
.error-type {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--error-light);
  color: var(--error);
  height: fit-content;
}
.error-detail { flex: 1; }
.error-words { margin-bottom: 2px; }
.error-words .wrong { color: var(--error); font-weight: 500; }
.error-words .arrow { color: var(--text-muted); margin: 0 4px; }
.error-words .right { color: var(--success); font-weight: 500; }
.error-explanation { color: var(--text-muted); font-size: 0.8125rem; }

.feedback-box {
  background: var(--success-light);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.9375rem;
  color: var(--success);
}

/* ── Views ───────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 40px rgba(0,0,0,.15);
}

/* ── Profile / Stats ─────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 6px; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.history-item:last-child { border-bottom: none; }
.history-meta { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.history-title { font-weight: 500; font-size: 0.9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-level { font-size: 0.75rem; color: var(--text-muted); padding: 2px 8px; border: 1px solid var(--border); border-radius: 100px; white-space: nowrap; }
.history-errors { font-size: 0.8125rem; color: var(--text-muted); white-space: nowrap; }
.history-date { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

/* ── Loading spinner ─────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Divider ─────────────────────────────────── */
.divider {
  text-align: center; color: var(--text-muted);
  font-size: 0.8125rem; margin: 12px 0; position: relative;
}
.divider::before {
  content: ''; position: absolute; top: 50%; left: 0; right: 0;
  height: 1px; background: var(--border);
}
.divider span { background: var(--surface); padding: 0 12px; position: relative; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .app-main { padding: 16px; }
  .level-grid { grid-template-columns: 1fr 1fr; }
  .app-header { padding: 0 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .level-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .history-item { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ── Controls del dictat (v6) ─────────────────── */
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }

.dictation-settings {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 4px 0 18px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.setting { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.setting input[type="range"] { width: 120px; accent-color: var(--primary); cursor: pointer; }
.setting input[type="checkbox"] { accent-color: var(--primary); cursor: pointer; width: 15px; height: 15px; }
.setting-value { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; min-width: 46px; }
.setting-hint { margin-left: auto; font-size: 0.75rem; }

/* La puntuació que no s'ha dictat es veu marcada, però no puntua: per això és
   un subratllat de punts i no el vermell dels errors. */
.word-warning {
  border-bottom: 2px dotted var(--warning);
  border-radius: 2px;
  padding: 0 2px;
  cursor: help;
}
.warnings-list { opacity: .9; }
.warnings-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* ── Rang i punts (F45) ───────────────────────── */
/* El rang és l'altre eix: l'escala diu com ha anat aquest dictat, això diu on
   ets en conjunt. Per això va en una targeta a part i no barrejat amb l'escala. */
.rank-block {
  margin: 20px 0 0;
  padding: 18px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
}
.rank-delta {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.rank-delta.gain { color: var(--success); }
.rank-delta.loss { color: var(--error); }
.rank-delta-note { font-size: .8125rem; color: var(--text-muted); margin-top: 2px; }

.rank-change {
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .9375rem;
  font-weight: 600;
}
.rank-change.up { background: var(--success-light); color: var(--success); }
.rank-change.down { background: var(--warning-light); color: var(--warning); }

.rank-now {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.rank-name { font-size: 1.0625rem; font-weight: 600; }
.rank-step { font-size: .75rem; color: var(--text-muted); font-weight: 400; margin-left: 6px; }
.rank-points { font-size: .875rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.rank-what { font-size: .8125rem; color: var(--text-muted); margin-top: 2px; }

.rank-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 6px;
}
.rank-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width .5s ease;
}
.rank-next { font-size: .8125rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
/* Quan el marge et protegeix però has caigut per sota del llindar (F50): no és
   un error, és tensió, i es llegeix millor si no va del color del text apagat. */
.rank-next-avis { color: var(--warning); font-weight: 500; }

/* Ratxa, comparació amb un mateix i fites (#23). Van sota les xifres del
   resultat, discretes: acompanyen, no criden. */
.anim-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 10px;
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
.anim-be { color: var(--success); font-weight: 500; }
.anim-fita { color: var(--primary); font-weight: 600; }
.anim-neutre { color: var(--text-muted); }

/* L'escala sencera, al perfil */
.rank-ladder { display: flex; flex-direction: column-reverse; gap: 2px; }
.rank-rung {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-left: 3px solid transparent;
  font-size: .875rem;
}
.rank-rung.assolit { color: var(--text); }
.rank-rung.pendent { color: var(--text-muted); opacity: .6; }
.rank-rung.actual {
  border-left-color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}
.rank-rung .rung-nom { min-width: 92px; }
.rung-que { font-size: .8125rem; color: var(--text-muted); font-weight: 400; flex: 1; }
.rung-punts { font-variant-numeric: tabular-nums; font-size: .8125rem; color: var(--text-muted); }

.peu-login {
  margin-top: 16px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.peu-login a { color: var(--primary); text-decoration: none; }
.peu-login a:hover { text-decoration: underline; }
.peu-legal { margin-top: 20px; font-size: 0.8125rem; }

/* Pàgines legals: privacitat i esborrat. Text llarg per llegir, no per fullejar. */
.pagina-legal {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  line-height: 1.7;
}
.pagina-legal h1 { font-size: 1.5rem; margin-bottom: 4px; }
.pagina-legal h2 {
  font-size: 1.0625rem;
  margin: 32px 0 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.pagina-legal p, .pagina-legal ul { margin-bottom: 12px; }
.pagina-legal ul { margin-left: 20px; }
.pagina-legal a { color: var(--primary); }

.taula-legal { width: 100%; border-collapse: collapse; margin: 12px 0 16px; font-size: 0.9375rem; }
.taula-legal th, .taula-legal td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.taula-legal th { color: var(--text-muted); font-weight: 600; font-size: 0.8125rem; }

/* Avisar sobre el contingut que escriu el model (F64).
   Discret: no ha de competir amb l'explicació, que és el que s'ha de llegir. */
.btn-avis {
  background: none;
  border: none;
  padding: 0 4px;
  margin-left: 6px;
  cursor: pointer;
  color: var(--text-muted);
  opacity: .45;
  font-size: .8125rem;
  line-height: 1;
  transition: opacity .15s, color .15s;
}
.btn-avis:hover:not(:disabled) { opacity: 1; color: var(--error); }
.btn-avis:focus-visible { opacity: 1; outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-avis.enviat { opacity: 1; color: var(--success); cursor: default; }
.error-explanation { display: flex; align-items: baseline; gap: 2px; }
.error-explanation > span { flex: 1; }

/* ── Accessibilitat (F39) ────────────────────────────────────
   Aquesta és una app que es fa servir amb les orelles: algú que la faci servir
   amb lector de pantalla n'és usuari de ple dret, no un cas límit. Fins ara no
   hi havia ni un atribut `aria-` a tot el frontend i el focus del teclat era el
   que posés el navegador per defecte, que a sobre d'un fons blanc gairebé no es
   veu.

   Els canvis d'estat es diuen a `aria-live="polite"` i mai `assertive`: mentre
   es dicta hi ha una veu sintètica parlant, i interrompre-la a cada frase faria
   la pantalla inservible en comptes d'accessible. */

/* El focus s'ha de veure sempre, i sobre qualsevol fons. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* El focus que es mou per codi —al resultat d'una correcció— no ha de pintar
   un requadre com si l'hagués posat el teclat: qui hi arriba amb el ratolí no
   entendria d'on surt. El lector de pantalla sí que el llegeix igual. */
[tabindex="-1"]:focus { outline: none; }

/* Text que només llegeix el lector de pantalla. No es pot fer amb
   `display:none` ni `visibility:hidden`: això l'amagaria també per a ell. */
.nomes-lector {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Qui ha demanat menys moviment al sistema no vol que això li tremoli. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Què has fet de cada text (F35) ─────────────
   Els dos colors estan mesurats amb `test/f39.contrast.js`:
   --success sobre --success-light 4,79:1 i --primary sobre --primary-light
   4,75:1, tots dos per sobre del 4,5:1 que demana l'AA. No canviar-los a ull. */
.text-marques { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.text-marques > span {
  font-size: 0.75rem;
  line-height: 1.4;
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.text-fet { color: var(--success); background: var(--success-light); }
.text-seguent { color: var(--primary); background: var(--primary-light); font-weight: 600; }

/* El text proposat es distingeix per la vora, no només pel color: qui no
   distingeix el blau del gris ha de poder veure igualment quin és. */
.text-item.es-seguent,
.mobile-text-item.es-seguent { border-color: var(--primary); background: var(--primary-light); }

.text-list-resum { font-size: 0.8125rem; color: var(--text-muted); margin-left: 8px; }

/* ── La corba de progrés (F36) ──────────────────
   `--text-muted` sobre `--surface` va a 5,83:1 i `--success` a 5,02:1, tots dos
   per sobre de l'AA. Mesurats amb `test/f39.contrast.js`, no triats a ull. */
.corba-nota { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.corba-millora:not(:empty) {
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--success);
  background: var(--success-light);
  border-radius: var(--radius);
  padding: 8px 10px;
}

/* ── De què són els teus errors (F26) ───────────
   Mesurat, no triat a ull: la part plena fa **3,18:1** contra el carril, per
   sobre del 3:1 que la WCAG 1.4.11 demana als gràfics que informen.

   El CARRIL, en canvi, fa 1,23:1 contra la targeta i no hi arriba. És a posta i
   és defensable perquè **el nombre sempre s'escriu al costat**: la barra és un
   suport per llegir la proporció d'un cop d'ull, no l'única manera de saber-la.
   Si algun dia el nombre desaparegués, això s'hauria de refer. */
.falles-titular:not(:empty) { margin: 0 0 14px; font-size: 0.9375rem; }
.falla { margin-bottom: 12px; }
.falla:last-child { margin-bottom: 0; }
.falla-cap { display: flex; align-items: baseline; gap: 8px; font-size: 0.875rem; }
.falla-nom { font-weight: 500; }
.falla-quants { margin-left: auto; color: var(--text-muted); font-size: 0.8125rem; }
.falla-barra {
  height: 6px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.falla-barra-plena { height: 100%; background: var(--primary-hover); opacity: .7; border-radius: 999px; }
.falla-regla { margin: 6px 0 0; font-size: 0.8125rem; color: var(--text-muted); }
.falla-resta { margin: 12px 0 0; font-size: 0.8125rem; color: var(--text-muted); }

/* La fitxa que resumeix una tirallonga de paraules no escrites. Va en gris i no
   en vermell a posta: no és una falta d'ortografia, és que el dictat s'ha
   deixat a mitges. */
.error-item.error-omeses .error-type { color: var(--text-muted); background: var(--bg); }
.error-item.error-omeses .wrong { color: var(--text-muted); text-decoration: none; }

/* ── El repàs de les frases fallades (F27) ──────
   Va amb el blau del tema i no en vermell: repassar no és una penalització. */
.repas-card { border-color: var(--primary); }
.repas-cos { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.repas-cos > div { flex: 1; min-width: 180px; }
.repas-titol { font-weight: 600; font-size: 0.9375rem; }
.repas-nota { font-size: 0.8125rem; color: var(--text-muted); margin-top: 2px; }

/* ── Micro-exercicis de 60 segons (F28) ─────────
   Els botons són grans a posta: es fan amb el dit i sense mirar gaire. */
.micro-cap { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.micro-cap .corba-nota { margin-left: auto; }
.micro-opcions { display: flex; flex-direction: column; gap: 12px; }
.micro-opcio {
  font-family: inherit;
  font-size: 1.375rem;
  font-weight: 600;
  padding: 20px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.micro-opcio:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.micro-opcio:disabled { cursor: default; opacity: .55; }
.micro-pista:not(:empty) {
  margin: 16px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.micro-entrada { display: block; text-align: center; text-decoration: none; }

/* ── Escriptura lliure (F29) ────────────────────
   El tema es llegeix com una consigna, no com un títol: va gros perquè és el
   que has de tenir al cap mentre escrius. */
.esc-tema { font-size: 1.0625rem; font-weight: 600; line-height: 1.4; }
.esc-item { cursor: pointer; }
.esc-peu { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.esc-peu .corba-nota { margin-right: auto; }
