@font-face {
  font-family: "OpenDyslexic";
  src: url("/assets/fonts/OpenDyslexic.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "Trebuchet";
  src: url("/assets/fonts/trebuchet.ttf") format("truetype");
  font-display: swap;
}

:root {
  /* Charte graphique PlanetExo.fr */
  --exo-blue-primary: #3399cc;
  --exo-blue-dark: #005588;
  --exo-blue-deeper: #03496c;
  --exo-blue-light: #33ccff;
  --exo-blue-bright: #01beff;
  --exo-blue-soft: #e3f4fc;
  --exo-bg-cream: #ebebe1;
  --exo-sand: #f1e8cb;
  --exo-pink: #da2475;
  --exo-gold: #d3ae22;
  --exo-green: #22a06b;
  --exo-red: #d93025;
  --exo-surface: #ffffff;
  --exo-text: #1e293b;
  --exo-muted: #5a6a7e;
  --exo-border: #d5dce4;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0, 85, 136, 0.08);
  --shadow-md: 0 8px 24px rgba(0, 85, 136, 0.14);

  --user-font-family: "Arial", system-ui, -apple-system, sans-serif;
  --user-font-size: 1.15rem;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--exo-bg-cream);
  color: var(--exo-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--exo-blue-dark) 0%, var(--exo-blue-primary) 100%);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(0, 85, 136, 0.22);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: #ffffff;
}

.brand-logo {
  border-radius: 50%;
  background: #ffffff;
  padding: 2px;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: #d9f3ff;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s ease, transform 0.1s ease;
}

.header-btn:hover, .header-btn:focus-visible {
  background: rgba(255, 255, 255, 0.26);
  outline: none;
}

.header-btn:active {
  transform: scale(0.97);
}

/* Main */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.hero-card {
  background: linear-gradient(135deg, #ffffff 0%, var(--exo-blue-soft) 100%);
  border: 2px solid var(--exo-blue-primary);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.hero-gus {
  width: 88px;
  height: 88px;
  object-fit: contain;
  flex-shrink: 0;
}

.hero-content h1 {
  margin: 0 0 0.4rem;
  font-size: 1.45rem;
  color: var(--exo-blue-dark);
}

.hero-content p {
  margin: 0;
  color: var(--exo-muted);
  font-size: 0.98rem;
}

.section-title {
  margin: 0 0 0.9rem;
  font-size: 1.2rem;
  color: var(--exo-blue-dark);
}

/* Levels Grid */
.levels-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.level-card {
  background: var(--exo-surface);
  border: 2px solid var(--exo-border);
  border-top: 6px solid var(--exo-blue-primary);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  min-height: 120px;
}

.level-card:hover, .level-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--exo-blue-primary);
  outline: none;
}

.level-ce1 { border-top-color: #33ccff; }
.level-ce2 { border-top-color: #3399cc; }
.level-cm1 { border-top-color: #d3ae22; }
.level-cm2 { border-top-color: #da2475; }

.level-badge {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--exo-blue-dark);
}

.level-desc {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--exo-text);
}

.level-meta {
  font-size: 0.85rem;
  color: var(--exo-muted);
}

.level-progress-bar {
  margin-top: 0.35rem;
  height: 8px;
  width: 100%;
  background: #e6ecf2;
  border-radius: 999px;
  overflow: hidden;
}

.level-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--exo-blue-light), var(--exo-blue-primary));
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* PlanetExo Banner */
.planetexo-banner {
  background: var(--exo-sand);
  border: 1px solid var(--exo-gold);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: flex-start;
  justify-content: space-between;
}

.planetexo-banner strong {
  color: var(--exo-blue-dark);
  font-size: 1.05rem;
}

.planetexo-banner p {
  margin: 0.25rem 0 0;
  font-size: 0.92rem;
  color: var(--exo-text);
}

/* Level View */
.level-header-bar {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.level-header-bar h1 {
  margin: 0;
  font-size: 1.55rem;
  color: var(--exo-blue-dark);
}

.muted-text {
  margin: 0.2rem 0 0;
  color: var(--exo-muted);
  font-size: 0.95rem;
}

.level-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-btn {
  min-height: 44px;
  padding: 0.45rem 1rem;
  border: 2px solid var(--exo-blue-primary);
  background: #ffffff;
  color: var(--exo-blue-dark);
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn.active, .chip-btn:hover {
  background: var(--exo-blue-primary);
  color: #ffffff;
}

/* Categories Accordion */
.categories-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.category-block {
  background: var(--exo-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--exo-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.category-header {
  width: 100%;
  min-height: 54px;
  padding: 0.85rem 1.15rem;
  background: var(--exo-blue-soft);
  border: none;
  border-bottom: 1px solid var(--exo-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--exo-blue-dark);
  cursor: pointer;
  text-align: left;
}

.category-list {
  display: flex;
  flex-direction: column;
}

.exercise-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.15rem;
  min-height: 56px;
  border: none;
  border-bottom: 1px solid #eef2f6;
  background: #ffffff;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 1rem;
  color: var(--exo-text);
  transition: background 0.12s ease;
}

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

.exercise-row:hover, .exercise-row:focus-visible {
  background: #f5fbff;
  outline: none;
}

.exercise-row-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.exercise-row-title {
  font-weight: 600;
}

.exercise-row-type {
  font-size: 0.78rem;
  color: var(--exo-muted);
}

.exercise-row-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--exo-blue-dark);
}

/* Lesson Card */
.card {
  background: var(--exo-surface);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--exo-border);
}

.lesson-header {
  border-bottom: 2px solid var(--exo-blue-soft);
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
}

.pill-tag {
  display: inline-block;
  background: var(--exo-blue-primary);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.45rem;
}

.lesson-header h1 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--exo-blue-dark);
}

.lesson-body {
  line-height: 1.7;
  color: var(--exo-text);
  margin-bottom: 1.5rem;
}

.lesson-highlight {
  color: var(--exo-red);
  font-weight: 700;
}

.lesson-footer {
  display: flex;
  justify-content: flex-end;
}

/* Exercise View */
.exercise-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.exercise-counter {
  font-weight: 800;
  font-size: 1rem;
  color: var(--exo-blue-dark);
  background: #ffffff;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--exo-border);
}

.exercise-top-actions {
  display: flex;
  gap: 0.5rem;
}

.exercise-banner {
  background: linear-gradient(135deg, var(--exo-blue-soft) 0%, #d4effc 100%);
  border: 2px solid var(--exo-blue-primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.exercise-prompt {
  flex: 1;
  text-align: center;
}

.exercise-instruction {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: var(--exo-blue-dark);
}

.exercise-question {
  margin: 0;
  font-weight: 600;
  color: var(--exo-text);
}

.timer-wrapper {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg {
  width: 56px;
  height: 56px;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: #ffffff;
  stroke-width: 4;
}

.timer-ring {
  fill: none;
  stroke: var(--exo-pink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s linear;
}

.timer-text {
  position: absolute;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--exo-blue-dark);
}

.feedback-badge {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Quiz choices */
.quiz-zone {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.quiz-choice-btn {
  min-height: 56px;
  padding: 0.85rem 1.2rem;
  background: #ffffff;
  border: 2px solid var(--exo-border);
  border-radius: var(--radius-md);
  font-size: var(--user-font-size);
  font-family: var(--user-font-family);
  font-weight: 600;
  color: var(--exo-text);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.quiz-choice-btn:hover:not(:disabled) {
  border-color: var(--exo-blue-primary);
  background: #f5fbff;
}

.quiz-choice-btn.correct {
  background: #e6f7ef;
  border-color: var(--exo-green);
  color: #0e5a3a;
}

.quiz-choice-btn.wrong {
  background: #fdecec;
  border-color: var(--exo-red);
  color: #8c1d18;
}

/* Sentence Zone */
.sentence-zone {
  background: #ffffff;
  border: 1px solid var(--exo-border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  text-align: center;
}

.sentence-display {
  line-height: 2;
  font-weight: 500;
}

.sentence-input {
  display: inline-block;
  min-width: 140px;
  max-width: 240px;
  min-height: 44px;
  padding: 0.25rem 0.65rem;
  margin: 0 0.25rem;
  font-family: var(--user-font-family);
  font-size: var(--user-font-size);
  font-weight: 700;
  color: var(--exo-blue-dark);
  border: 2px solid var(--exo-blue-primary);
  border-radius: var(--radius-sm);
  background: #f8fcff;
  text-align: center;
}

.sentence-input:focus {
  outline: none;
  border-color: var(--exo-blue-dark);
  box-shadow: 0 0 0 3px rgba(51, 153, 204, 0.25);
}

.sentence-input.is-correct {
  border-color: var(--exo-green);
  background: #e6f7ef;
  color: #0e5a3a;
}

.sentence-input.is-wrong {
  border-color: var(--exo-red);
  background: #fdecec;
}

.sentence-hint {
  font-size: 0.88rem;
  color: var(--exo-muted);
}

.solution-toast {
  margin-top: 1rem;
  padding: 0.85rem 1.15rem;
  background: var(--exo-sand);
  border-left: 5px solid var(--exo-gold);
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--exo-blue-dark);
}

/* User Typography & Colorization */
.user-styled-text {
  font-family: var(--user-font-family);
  font-size: var(--user-font-size);
}

.char-vowel { color: #0044cc; }
.char-consonant { color: #cc1122; }
.char-alt-even { color: #0044cc; }
.char-alt-odd { color: #cc1122; }

/* Buttons */
.btn-primary, .btn-secondary, .btn-outline-sm, .btn-danger-sm {
  min-height: 44px;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-lg {
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  font-size: 1.02rem;
}

.btn-primary {
  background: var(--exo-blue-primary);
  color: #ffffff;
}
.btn-primary:hover { background: var(--exo-blue-dark); }

.btn-secondary {
  background: var(--exo-blue-dark);
  color: #ffffff;
}
.btn-secondary:hover { background: var(--exo-blue-deeper); }

.btn-outline-sm {
  background: #ffffff;
  color: var(--exo-blue-dark);
  border: 1.5px solid var(--exo-blue-primary);
}
.btn-outline-sm:hover { background: var(--exo-blue-soft); }

.btn-danger-sm {
  background: #ffffff;
  color: var(--exo-red);
  border: 1.5px solid #f2b8b5;
}
.btn-danger-sm:hover { background: #fdecec; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 73, 108, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

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

.modal-header h2, .results-card h2 {
  margin: 0;
  color: var(--exo-blue-dark);
}

.btn-close-x {
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  color: var(--exo-muted);
}

.results-stats {
  margin: 1rem 0;
  border: 1px solid var(--exo-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f0f4f8;
}
.stat-row:last-child { border-bottom: none; }

.results-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin: 1rem 0;
}

.stars-row {
  display: flex;
  gap: 0.4rem;
}

.results-encouragement {
  text-align: center;
  font-weight: 700;
  color: var(--exo-blue-dark);
  margin: 0.5rem 0 1.25rem;
}

.modal-actions, .settings-footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.2rem;
}

/* Settings */
.settings-section {
  margin-bottom: 1.25rem;
}

.settings-section h3 {
  margin: 0 0 0.7rem;
  padding: 0.45rem 0.75rem;
  background: var(--exo-blue-soft);
  color: var(--exo-blue-dark);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.setting-row label {
  font-weight: 700;
  font-size: 0.92rem;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  border: 1.5px solid var(--exo-blue-primary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segmented-control button {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0.45rem 0.65rem;
  border: none;
  border-right: 1px solid var(--exo-border);
  background: #ffffff;
  color: var(--exo-text);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

.segmented-control button:last-child { border-right: none; }
.segmented-control button.active {
  background: var(--exo-blue-dark);
  color: #ffffff;
}

/* Cookie Banner */
.cookie-banner {
  position: fixed;
  bottom: 0.85rem;
  left: 0.85rem;
  right: 0.85rem;
  max-width: 780px;
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid var(--exo-blue-dark);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 90;
}

.cookie-banner p {
  margin: 0;
  font-size: 0.9rem;
}

.cookie-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* Footer */
.app-footer {
  background: var(--exo-blue-deeper);
  color: #d9f3ff;
  padding: 1rem;
  font-size: 0.88rem;
}

.footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.app-footer a, .link-btn {
  color: #ffffff;
  text-decoration: underline;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0.25rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem;
}

/* Breakpoints Desktop / Tablette */
@media (min-width: 640px) {
  .hero-card {
    flex-direction: row;
    text-align: left;
    padding: 1.5rem 2rem;
  }

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

  .planetexo-banner {
    flex-direction: row;
    align-items: center;
  }

  .level-header-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

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

  .cookie-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
  }
}

@media (min-width: 920px) {
  .levels-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 420px) {
  .hide-xs { display: none; }
}

