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

html,
body {
  min-height: 100%;
}

body {
  font-family: 'Nunito', 'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
  background: #F6F1E7;
  color: #221F1B;
}

:root {
  --paper: #F6F1E7;
  --ink: #221F1B;
  --green: #2F6B3A;
  --green-dark: #245430;
  --green-soft: #E3EDE4;
  --accent: #C96F4A;
  --gold: #B97A1E;
  --red: #C0392B;
  --blue: #2B6CB0;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

html {
  -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible,
.option:focus-visible {
  outline: 3px solid #1cb0f6;
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #58cc02;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 0 0 12px 0;
  font-weight: 800;
  z-index: 200;
}

.skip-link:focus {
  left: 0;
}

#app {
  min-height: 100vh;
}

.hero h1,
.hero h2,
.unit-titles h2,
.exercise-text,
.complete-card h1,
.fail-card h1 {
  text-wrap: balance;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 2px solid #e5e5e5;
}

.topbar-left {
  font-size: 20px;
  font-weight: 900;
  color: var(--green);
}

.topbar-stats {
  display: flex;
  gap: 14px;
  align-items: center;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.stat.streak {
  color: #9A5B00;
}

.stat.xp {
  color: #17658F;
}

.stat.hearts {
  color: #C0392B;
  font-size: 17px;
}

/* ============ HOME ============ */
.home-content {
  max-width: 620px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.hero {
  background: linear-gradient(135deg, #2F6B3A 0%, #3E7D4E 100%);
  border-radius: 24px;
  padding: 28px 24px;
  color: #ffffff;
  text-align: center;
  margin-bottom: 28px;
  box-shadow: 0 6px 0 #245430;
}

.hero h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 34px;
  font-weight: 700;
  margin-bottom: 8px;
  text-wrap: balance;
}

.hero p {
  font-size: 17px;
  font-weight: 700;
  opacity: 0.95;
}

.back-link {
  display: inline-block;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  margin-bottom: 14px;
  padding: 4px 8px;
  border-radius: 8px;
}

.back-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.tif-group-cta {
  display: flex;
  justify-content: center;
  margin: 4px 0 28px;
}

a.btn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.unit-card {
  border: 2px solid #e5e5e5;
  border-radius: 20px;
  margin-bottom: 28px;
  overflow: hidden;
}

.unit-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: #f7ffe0;
  border-bottom: 2px solid #e5e5e5;
}

.unit-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--unit-color, #58cc02);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.unit-titles {
  flex: 1;
}

.unit-titles h2 {
  font-size: 19px;
  font-weight: 800;
}

.unit-titles p {
  font-size: 13px;
  font-weight: 600;
  color: #5F574C;
}

.unit-progress {
  background: #e5e5e5;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 800;
  color: #4F473D;
}

.lesson-list {
  position: relative;
  padding: 18px 16px;
}

.lesson-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  text-decoration: none;
  color: inherit;
}

.lesson-row.locked {
  opacity: 1;
  cursor: not-allowed;
}

.lesson-row.locked .node {
  opacity: 0.55;
}

.lesson-row .node {
  flex-shrink: 0;
}

.lesson-meta {
  flex: 1;
}

.lesson-meta h3 {
  font-size: 16px;
  font-weight: 800;
}

.lesson-meta p {
  font-size: 13px;
  font-weight: 600;
  color: #5F574C;
}

.lesson-row.locked .lesson-meta h3,
.lesson-row.locked .lesson-meta p {
  color: #5F574C;
}

.lesson-xp {
  font-size: 13px;
  font-weight: 800;
  color: #17658F;
}

.node {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid var(--unit-color, #58cc02);
  background: #ffffff;
  color: var(--unit-color, #58cc02);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  flex-shrink: 0;
}

.node.done {
  background: var(--unit-color, #58cc02);
  color: #ffffff;
}

.node.current {
  background: var(--unit-color, #58cc02);
  color: #ffffff;
  animation: node-pulse 1.6s ease-in-out infinite;
}

@keyframes node-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(88, 204, 2, 0.5); }
  50% { box-shadow: 0 0 0 12px rgba(88, 204, 2, 0); }
}

.node.locked {
  border-color: #e5e5e5;
  color: #e5e5e5;
  background: #ffffff;
}

.node.todo {
  border-color: #e5e5e5;
  color: #e5e5e5;
  background: #ffffff;
}

/* ============ LESSON SCREEN ============ */
.lesson-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.lesson-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
}

.lesson-top .close {
  font-size: 22px;
  color: #afafaf;
  padding: 6px;
}

.progress-track {
  flex: 1;
  height: 16px;
  background: #e5e5e5;
  border-radius: 999px;
  overflow: hidden;
}

.progress-track.slim {
  flex: 1;
  height: 10px;
  background: #e5e5e5;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  background: #2F6B3A;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.hearts-inline {
  font-size: 20px;
  font-weight: 800;
  color: #ff4b4b;
}

.lesson-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 20px 110px;
  max-width: 620px;
  width: 100%;
  margin: 0 auto;
}

.exercise-kicker {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #17658F;
  margin-bottom: 12px;
}

.exercise-text {
  font-size: 38px;
  font-weight: 900;
  text-align: center;
  word-break: break-word;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 32px;
}

.option {
  border: 2px solid #e5e5e5;
  border-radius: 14px;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  background: #ffffff;
  color: #3c3c3c;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.option:hover {
  border-color: #58cc02;
}

.option.selected-correct {
  border-color: #58cc02;
  background: #d7ffb8;
  color: #46a302;
}

.option.selected-wrong {
  border-color: #ff4b4b;
  background: #ffdfe0;
  color: #ff4b4b;
}

/* ============ FEEDBACK ============ */
.feedback {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  z-index: 40;
}

.feedback.correct {
  background: #E3EDE4;
  border-top: 2px solid #2F6B3A;
}

.feedback.wrong {
  background: #ffdfe0;
  border-top: 2px solid #ff4b4b;
}

.feedback-inner {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.feedback-text {
  flex: 1;
}

.feedback-text h3 {
  font-size: 20px;
  font-weight: 900;
}

.feedback-text.correct h3 { color: #46a302; }
.feedback-text.wrong h3 { color: #ff4b4b; }

.feedback-text p {
  font-size: 15px;
  font-weight: 700;
  color: #6B6357;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #ffffff;
  transition: filter 0.1s, transform 0.05s;
}

.btn-green {
  background: #2F6B3A;
  box-shadow: 0 4px 0 #245430;
}

.btn-red {
  background: #ff4b4b;
  box-shadow: 0 4px 0 #d33131;
}

.btn-blue {
  background: #1cb0f6;
  box-shadow: 0 4px 0 #1899d6;
}

.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: none; }

.btn:disabled {
  background: #e5e5e5;
  box-shadow: 0 4px 0 #d4d4d4;
  color: #afafaf;
  cursor: not-allowed;
}

/* ============ COMPLETE / FAIL ============ */
.complete-screen,
.fail-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.complete-card,
.fail-card {
  background: #ffffff;
  border: 2px solid #e5e5e5;
  border-radius: 24px;
  padding: 40px 28px;
  text-align: center;
  max-width: 480px;
  width: 100%;
}

.complete-card .trophy,
.fail-card .trophy {
  font-size: 72px;
  margin-bottom: 16px;
}

.complete-card h1,
.fail-card h1 {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 12px;
}

.complete-card .xp-earned {
  font-size: 34px;
  font-weight: 900;
  color: #1cb0f6;
  margin-bottom: 8px;
}

.complete-card .accuracy,
.complete-card .score {
  font-size: 17px;
  font-weight: 700;
  color: #777777;
  margin-bottom: 20px;
}

.new-badges {
  margin: 20px 0;
}

.new-badges h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  color: #ffc800;
}

.new-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff8e0;
  border: 2px solid #ffc800;
  border-radius: 999px;
  padding: 8px 16px;
  margin: 0 6px 8px 0;
  font-weight: 800;
  font-size: 14px;
  animation: badge-pop 0.5s ease;
}

@keyframes badge-pop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.complete-actions {
  margin-top: 24px;
}

.fail-card p {
  color: #777777;
  font-weight: 600;
  margin-bottom: 24px;
}

/* ============ CONFETTI ============ */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 100;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ TIFINAGH MODULE ============ */
.tif-audio,
.tif-sign,
.tif-matching,
.tif-word,
.tif-tracing {
  margin-top: 28px;
}

.tif-hint {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: #6B6258;
  margin-top: 16px;
  line-height: 1.5;
}

.tif-hint strong {
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.tif-sign {
  text-align: center;
}

.tif-sign-symbol {
  font-size: 90px;
  font-weight: 900;
  color: var(--green);
  margin: 20px 0;
  line-height: 1;
}

.tif-audio {
  text-align: center;
}

.options-symbols .option,
.option-symbol {
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  color: var(--green);
}

.tif-canvas-wrap {
  max-width: 320px;
  margin: 0 auto;
}

.tif-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border: 2px solid #E4DACA;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 50%, #FFFFFF 0%, #FCFAF5 100%);
  touch-action: none;
  cursor: crosshair;
  box-shadow: inset 0 2px 10px rgba(34, 31, 27, 0.05);
}

.tif-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

.pairs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.pair-card {
  min-height: 66px;
  border: 2px solid #E4DACA;
  border-radius: 16px;
  padding: 12px;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.pair-card:not(:disabled):hover {
  border-color: #CDBFA9;
  transform: translateY(-1px);
}

.pair-card.selected {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 0 0 3px rgba(47, 107, 58, 0.12);
}

.pair-card.wrong {
  border-color: var(--red);
  background: #FBEAE8;
  animation: shake 0.32s ease;
}

.pair-card.matched {
  border-color: #BBD6BE;
  background: #F1F7F1;
  opacity: 0.45;
  cursor: default;
}

.pair-symbol {
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
}

.pair-sound {
  font-size: 22px;
  font-weight: 800;
  color: var(--green);
}

.word-blocks {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.word-block {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 2px solid var(--green);
  background: #FFFFFF;
  color: var(--green);
  font-size: 34px;
  font-weight: 900;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.word-block:not(:disabled):hover {
  transform: translateY(-2px);
}

.word-block.used {
  opacity: 0.25;
  border-color: #E4DACA;
  color: #A69C8E;
}

.word-built {
  margin-top: 14px;
  font-size: 34px;
  font-weight: 900;
  min-height: 46px;
  text-align: center;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.btn-ghost {
  background: transparent;
  color: #6B6258;
  border: 2px solid #E4DACA;
  padding: 10px 18px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 15px;
}

.btn-ghost:hover:not(:disabled) {
  border-color: #CDBFA9;
  color: var(--ink);
}

.btn-ghost:disabled {
  opacity: 0.4;
  cursor: default;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ============ PWA ============ */
.pwa-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 14px;
  border: 2px solid #E4DACA;
  border-radius: 18px;
  background: #FFFDF8;
  box-shadow: 0 12px 32px rgba(34, 31, 27, 0.18);
  animation: pwa-rise 0.28s ease-out;
}

.pwa-banner[hidden] {
  display: none;
}

.pwa-banner img {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.pwa-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pwa-banner-text strong {
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.2;
}

.pwa-banner-text span {
  font-size: 12.5px;
  font-weight: 700;
  color: #6B6258;
  line-height: 1.35;
}

.pwa-banner .btn.pwa-install,
.pwa-banner .btn.pwa-reload {
  flex-shrink: 0;
  width: auto;
  padding: 10px 16px;
  font-size: 13px;
  letter-spacing: 0.4px;
  box-shadow: 0 3px 0 #245430;
}

.pwa-dismiss {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8A8071;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.pwa-dismiss:hover {
  background: #F1EADC;
  color: var(--ink);
}

.pwa-banner-update {
  border-color: #CDBFA9;
}

.pwa-offline {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(34, 31, 27, 0.22);
}

.pwa-offline[hidden] {
  display: none;
}

@keyframes pwa-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 380px) {
  .pwa-banner {
    left: 10px;
    right: 10px;
    width: calc(100% - 20px);
    gap: 9px;
    padding: 10px;
  }

  .pwa-banner img {
    width: 38px;
    height: 38px;
  }

  .pwa-banner-text strong {
    font-size: 14px;
  }

  .pwa-banner-text span {
    font-size: 11.5px;
  }

  .pwa-banner .btn.pwa-install,
  .pwa-banner .btn.pwa-reload {
    padding: 9px 12px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-banner {
    animation: none;
  }
}

/* ============ FOOTER ============ */
.home-footer {
  margin: 4px 0 24px;
  padding: 22px 20px;
  border-radius: 20px;
  border: 2px dashed #CDBFA9;
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.home-footer a {
  display: inline-block;
  font-size: 16px;
  font-weight: 900;
  color: var(--green);
  text-decoration: none;
}

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

.home-footer p {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: #5F574C;
}

/* ============ TOPBAR ACTIONS ============ */
.topbar-left {
  text-decoration: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.topbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #F2EDE3;
  font-size: 17px;
  text-decoration: none;
  line-height: 1;
}

.topbar-icon:hover {
  background: #E4DACA;
}

.topbar-avatar {
  background: var(--green-soft);
}

/* ============ HERO ACTIONS ============ */
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.hero-actions .btn.hero-btn {
  width: auto;
  padding: 11px 16px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--green);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  font-size: 13px;
}

.hero-actions .btn.hero-btn:hover {
  filter: brightness(0.97);
}

/* ============ PROFIL ============ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: #6B6357;
  font-weight: 700;
}

.profile-content {
  max-width: 720px;
}

.profile-hero {
  text-align: left;
  padding: 24px;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid rgba(255, 255, 255, 0.35);
  font-size: 40px;
  line-height: 1;
}

.profile-identity-text h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 30px;
  font-weight: 700;
  margin: 0;
  text-wrap: balance;
}

.profile-identity-text p {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 700;
  opacity: 0.92;
}

.profile-identity-text .profile-next {
  font-size: 13px;
  opacity: 0.8;
}

.goal-card {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
}

.goal-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 15px;
  font-weight: 900;
}

.goal-card .progress-track {
  background: rgba(255, 255, 255, 0.25);
}

.goal-card .progress-fill {
  background: #ffffff;
}

.goal-card p {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.9;
}

.profile-section {
  margin: 0 0 18px;
  padding: 20px;
  border-radius: 20px;
  border: 2px solid #E5E0D5;
  background: #ffffff;
}

.profile-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 19px;
}

.profile-section h2 .muted {
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  list-style: none;
}

.stat-tile {
  display: grid;
  gap: 2px;
  padding: 12px;
  border-radius: 14px;
  background: var(--paper);
  text-align: center;
}

.stat-tile-icon {
  font-size: 20px;
}

.stat-tile-value {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.stat-tile-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #6B6357;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  list-style: none;
}

.badge-tile {
  display: grid;
  gap: 3px;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid #E5E0D5;
}

.badge-tile.owned {
  border-color: #BFD8C2;
  background: #F1F7F1;
}

.badge-tile.locked {
  background: #FAF8F3;
  border-style: dashed;
}

.badge-tile.locked .badge-title,
.badge-tile.locked .badge-desc {
  color: #5F574C;
}

.badge-icon {
  font-size: 22px;
}

.badge-title {
  font-size: 14px;
  font-weight: 900;
}

.badge-desc {
  font-size: 12px;
  line-height: 1.4;
  color: #6B6357;
}

.badge-state {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--green);
}

.badge-tile.locked .badge-state {
  color: #6B6357;
}

.profile-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.field legend {
  font-size: 14px;
  font-weight: 800;
}

.field input[type='text'],
.field select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 2px solid #E0D8C8;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.field input[type='text']:focus,
.field select:focus {
  outline: 3px solid #1cb0f6;
  outline-offset: 1px;
  border-color: #1cb0f6;
}

.field-help {
  margin: 0;
  font-size: 12px;
  color: #6B6357;
}

.avatar-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.avatar-choice {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.avatar-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.avatar-choice-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #E0D8C8;
  background: var(--paper);
  font-size: 22px;
  line-height: 1;
}

.avatar-choice input:checked + .avatar-choice-emoji {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 0 0 2px rgba(47, 107, 58, 0.2);
}

.avatar-choice input:focus-visible + .avatar-choice-emoji {
  outline: 3px solid #1cb0f6;
  outline-offset: 2px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.switch-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.form-status {
  min-height: 20px;
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--green);
}

.form-status.is-error {
  color: var(--red);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.data-actions .btn {
  width: auto;
  padding: 12px 16px;
  font-size: 12px;
}

.btn-secondary {
  background: #ffffff;
  color: var(--green);
  border: 2px solid var(--green);
  box-shadow: 0 4px 0 #C9DCCD;
}

.btn-danger {
  background: #ffffff;
  color: var(--red);
  border: 2px solid var(--red);
  box-shadow: 0 4px 0 #F0C9C4;
}

@media (max-width: 480px) {
  .topbar {
    padding: 10px 12px;
  }

  .topbar-left {
    font-size: 16px;
  }

  .topbar-right {
    gap: 6px;
  }

  .topbar-stats {
    gap: 8px;
  }

  .stat {
    font-size: 13px;
  }

  .stat.hearts {
    font-size: 15px;
  }

  .topbar-icon {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .hero-actions .btn.hero-btn {
    flex: 1 1 130px;
  }

  .profile-hero {
    padding: 20px 16px;
  }

  .profile-identity {
    align-items: flex-start;
    gap: 12px;
  }

  .profile-avatar {
    width: 60px;
    height: 60px;
    font-size: 32px;
  }

  .profile-identity-text h1 {
    font-size: 24px;
  }

  .profile-section {
    padding: 16px;
  }

  .data-actions .btn {
    width: 100%;
  }
}

/* Très petits écrans : garder la marque sur une seule ligne. */
@media (max-width: 360px) {
  .topbar {
    padding: 8px 10px;
  }

  .topbar-left {
    font-size: 14px;
    white-space: nowrap;
  }

  .topbar-right {
    gap: 4px;
  }

  .topbar-stats {
    gap: 6px;
  }

  .stat {
    font-size: 12px;
  }

  .stat.hearts {
    font-size: 14px;
  }

  .topbar-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 480px) {
  .exercise-text { font-size: 30px; }
  .feedback-inner { flex-direction: column; align-items: flex-start; }
}

/* ============ PRATIQUE LIBRE (accueil) ============ */
.practice-section {
  margin: 0 0 28px;
}

.practice-head h2 {
  font-size: 21px;
  font-weight: 900;
}

.practice-head p {
  margin: 4px 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: #5F574C;
}

.practice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.practice-card {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 18px 18px 16px;
  border-radius: 20px;
  border: 2px solid #E5E0D5;
  background: #ffffff;
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.practice-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
}

.practice-card-review {
  background: linear-gradient(135deg, #F1F7F1 0%, #ffffff 100%);
}

.practice-icon {
  font-size: 24px;
  line-height: 1;
}

.practice-title {
  font-size: 16px;
  font-weight: 900;
}

.practice-desc {
  padding-right: 30px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.35;
  color: #6B6357;
}

.practice-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--paper);
  color: #6B6357;
  font-size: 12px;
  font-weight: 900;
}

.practice-badge.is-due {
  background: #A9542F;
  color: #ffffff;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
}

/* ============ RÉVISION ESPACÉE ============ */
.practice-hero {
  padding-bottom: 24px;
}

.srs-summary {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 16px;
  padding: 18px 20px;
  border-radius: 20px;
  border: 2px solid #E5E0D5;
  background: #ffffff;
}

.srs-big {
  display: grid;
  gap: 3px;
  min-width: 96px;
  text-align: center;
}

.srs-big strong {
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.srs-big span {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #6B6357;
}

.srs-meta p {
  margin: 2px 0;
  font-size: 13px;
  font-weight: 700;
  color: #5F574C;
}

.srs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 20px;
}

.srs-actions .btn {
  flex: 1 1 180px;
  width: auto;
  padding: 13px 18px;
  font-size: 13px;
}

.srs-preview {
  display: grid;
  gap: 8px;
  list-style: none;
}

.srs-preview li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--paper);
}

.srs-kab {
  font-weight: 900;
}

.srs-fr {
  font-weight: 700;
  color: #5F574C;
}

.srs-box {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--green);
}

.srs-note {
  margin: 16px 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  color: #6B6357;
}

.srs-counter {
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  color: var(--green);
}

.srs-next {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #6B6357;
}

.option-correct {
  border-color: #58cc02;
  background: #f1fbe8;
}

.empty-card {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 18px;
  border-radius: 16px;
  border: 2px dashed #CDBFA9;
  background: rgba(255, 255, 255, 0.6);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
  color: #5F574C;
}

.empty-card .btn {
  width: auto;
  padding: 11px 18px;
  font-size: 12px;
}

/* ============ ATELIERS DE PHRASES ============ */
.phrase-intro {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: #ffffff;
  border: 2px solid #E5E0D5;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
  color: #3C372F;
}

.phrase-intro .muted {
  font-size: 12.5px;
}

.workshop-list {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.workshop-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 2px solid #E5E0D5;
  border-left: 6px solid var(--workshop-color, #2F6B3A);
  background: #ffffff;
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.workshop-card:hover {
  transform: translateY(-2px);
  border-color: var(--workshop-color, #2F6B3A);
}

.workshop-card.is-done {
  background: #F7FBF7;
}

.workshop-emoji {
  font-size: 28px;
  line-height: 1;
}

.workshop-body {
  display: grid;
  gap: 2px;
  flex: 1;
}

.workshop-level {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--workshop-color, #2F6B3A);
}

.workshop-title {
  font-size: 17px;
  font-weight: 900;
}

.workshop-subtitle {
  font-size: 13px;
  font-weight: 700;
  color: #5F574C;
}

.workshop-count {
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 700;
  color: #6B6357;
}

.workshop-arrow {
  font-size: 20px;
  font-weight: 900;
  color: var(--workshop-color, #2F6B3A);
}

.build-body {
  justify-content: flex-start;
  gap: 14px;
  padding-top: 12px;
}

.build-prompt {
  font-size: 24px;
  font-weight: 900;
  text-align: center;
}

.build-answer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  padding: 12px;
  border-bottom: 2px solid #e5e5e5;
}

.build-placeholder {
  font-size: 13px;
  font-weight: 700;
  color: #6B6357;
}

.build-token {
  padding: 9px 14px;
  border-radius: 12px;
  border: 2px solid #D9D2C4;
  background: #ffffff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 2px 0 #E2DCCF;
  transition: border-color 0.12s ease, transform 0.05s ease;
}

.build-token:hover {
  border-color: var(--green);
}

.build-token-answer {
  border-color: #BFD8C2;
  background: #F1F7F1;
}

.build-token.used {
  opacity: 0.35;
  box-shadow: none;
}

.build-toolbar {
  display: flex;
  justify-content: center;
}

.build-bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  background: var(--paper);
}

.build-note {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  color: #6B6357;
}

.link-button {
  padding: 6px;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  text-decoration: underline;
  color: #6B6357;
}

.link-button:disabled {
  color: #B3ADA2;
  text-decoration: none;
  cursor: not-allowed;
}

/* ============ PRONONCIATION ============ */
.pron-notice {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.pron-notice.is-ok {
  border: 2px solid #BFD8C2;
  background: #E3EDE4;
  color: #245430;
}

.pron-notice.is-warning {
  border: 2px solid #F0D9AE;
  background: #FFF4E0;
  color: #7A4E10;
}

.pron-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 16px;
  list-style: none;
}

.pron-stats li {
  display: grid;
  gap: 2px;
  padding: 12px 6px;
  border-radius: 14px;
  border: 2px solid #E5E0D5;
  background: #ffffff;
  text-align: center;
}

.pron-stats span {
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.pron-stats small {
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #6B6357;
}

.pron-list {
  display: grid;
  gap: 8px;
  list-style: none;
}

.pron-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--paper);
}

.pron-item-text {
  display: grid;
  gap: 1px;
  flex: 1;
}

.pron-item-text strong {
  font-size: 15px;
}

.pron-item-text span {
  font-size: 12px;
  font-weight: 700;
  color: #6B6357;
}

.pron-listen {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #E0D8C8;
  background: #ffffff;
  font-size: 16px;
}

.pron-listen:hover {
  border-color: var(--green);
}

.pron-body {
  justify-content: flex-start;
  gap: 10px;
  padding-top: 10px;
}

.pron-word {
  font-size: 34px;
  font-weight: 900;
  text-align: center;
  word-break: break-word;
}

.pron-fr {
  font-weight: 800;
  text-align: center;
  color: #6B6357;
}

.pron-tip {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  color: #5F574C;
}

.pron-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.pron-controls .btn {
  flex: 1 1 180px;
  width: auto;
  padding: 13px 18px;
  font-size: 13px;
}

.pron-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.pron-actions .btn {
  width: auto;
  padding: 11px 18px;
  font-size: 12px;
}

.pron-result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 2px solid #E5E0D5;
  background: #ffffff;
}

.pron-score {
  display: grid;
  gap: 2px;
  min-width: 78px;
  text-align: center;
}

.pron-score strong {
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pron-score span {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.4px;
  color: #6B6357;
}

.pron-result-text h3 {
  font-size: 16px;
  font-weight: 900;
}

.pron-result-text p {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: #5F574C;
}

.pron-transcript {
  font-style: italic;
  color: #6B6357;
}

.pron-result.great {
  border-color: #BFD8C2;
  background: #F1F7F1;
}

.pron-result.great .pron-score strong,
.pron-result.good .pron-score strong {
  color: #2F8A3C;
}

.pron-result.ok {
  border-color: #CFE0EC;
  background: #F2F8FD;
}

.pron-result.ok .pron-score strong {
  color: var(--blue);
}

.pron-result.close {
  border-color: #F0D9AE;
  background: #FFF9EE;
}

.pron-result.close .pron-score strong {
  color: #B97A1E;
}

.pron-result.low {
  border-color: #EFC4BE;
  background: #FDF3F2;
}

.pron-result.low .pron-score strong {
  color: var(--red);
}

@media (max-width: 480px) {
  .practice-grid {
    grid-template-columns: 1fr;
  }

  .srs-summary {
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .pron-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .pron-word {
    font-size: 28px;
  }

  .build-prompt {
    font-size: 21px;
  }
}
