/* Bristol: "iOS touch" soft UI. Rounded cards, tinted soft shadows, vivid gradients.
   Color is information: blue = action and selection, green = right, red = wrong,
   orange = middling score, one gradient (a–e) per subject. */

@font-face {
  font-family: "Nunito";
  src: url("../fonts/nunito-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

/* --- Tokens --------------------------------------------------------------- */

:root {
  color-scheme: light;
  --bg: #EEF1F8;
  --surface: #FFFFFF;
  --surface-alt: #F5F7FC;
  --text-primary: #2B2F45;
  --text-secondary: #6E7491; /* design system's #8A8FA3, darkened to reach 4.5:1 */
  --border-subtle: #E4E8F2;
  --glass: rgba(255, 255, 255, 0.74);
  --glass-edge: rgba(255, 255, 255, 0.7);

  --accent-blue: #4E7FEF;
  --accent-blue-ink: #3A67E0;
  --accent-blue-soft: #E7EEFF;
  --accent-green: #34C85A;
  --accent-green-strong: #1FA84A;
  --accent-green-ink: #13843A;
  --accent-green-soft: #E2F7E8;
  --accent-red: #F0445A;
  --accent-red-ink: #C8243D;
  --accent-red-soft: #FFE7EB;
  --accent-orange: #FFA53E;
  --accent-orange-ink: #A45200;
  --accent-orange-soft: #FFF0DC;
  --accent-violet: #8C6FF7;
  --accent-violet-ink: #6445D8;
  --accent-violet-soft: #F0EBFF;

  --gradient-brand: linear-gradient(150deg, #6A95FF 0%, #3A67E0 100%);
  --gradient-a: linear-gradient(135deg, #FF6FA5, #8C6FF7);
  --gradient-b: linear-gradient(135deg, #33C2D6, #3E7BFA);
  --gradient-c: linear-gradient(135deg, #FFB547, #FF5C6C);
  --gradient-d: linear-gradient(135deg, #3DDC97, #16A6B8);
  --gradient-e: linear-gradient(135deg, #B07CFF, #5B5CF0);

  --shadow-card: 0 8px 24px rgba(70, 90, 160, 0.12);
  --shadow-soft: 0 4px 14px rgba(70, 90, 160, 0.08);
  --shadow-button: 0 6px 16px rgba(78, 127, 239, 0.28);
  --shadow-bar: 0 10px 30px rgba(70, 90, 160, 0.18);
  --on-color-shadow: 0 1px 2px rgba(40, 20, 90, 0.28);

  --radius-card: 24px;
  --radius-row: 16px;
  --radius-tile: 14px;
  --radius-button: 18px;
  --gutter: 16px;

  /* Progression curve: knowledge (blue) and coverage (orange), checked with the dataviz
     palette validator against the light surface (#FFFFFF) and the dark one (#1C1E2A). */
  --series-knowledge: #3A67E0;
  --series-coverage: #D9730D;
  /* Knowledge states, best known first. Mastered shares the knowledge blue; the three
     hues pass the same validator (blue/amber/red stay apart for colour-blind readers).
     "Never seen" is a neutral, not a hue: it is the absence of data. */
  --state-mastered: #3A67E0;
  --state-fragile: #E2A21B;
  --state-to_review: #D64545;
  --state-unseen: #D5DAE6;

  --font: ui-rounded, "SF Pro Rounded", "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* Emoji first: some text fonts carry monochrome versions of symbols such as ⚛. */
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", var(--font);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --tabbar-space: calc(96px + env(safe-area-inset-bottom));
}

/* Dark theme: follows the system, unless "Mon espace" forces one (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14151F;
    --surface: #1C1E2A;
    --surface-alt: #252838;
    --text-primary: #F1F2F8;
    --text-secondary: #A3A8BF;
    --border-subtle: #2E3145;
    --glass: rgba(30, 32, 46, 0.74);
    --glass-edge: rgba(255, 255, 255, 0.07);

    --accent-blue-ink: #8FB0FF;
    --accent-blue-soft: rgba(78, 127, 239, 0.2);
    --accent-green-ink: #6BE08F;
    --accent-green-soft: rgba(52, 200, 90, 0.16);
    --accent-red-ink: #FF8C9C;
    --accent-red-soft: rgba(240, 68, 90, 0.18);
    --accent-orange-ink: #FFC07A;
    --accent-orange-soft: rgba(255, 165, 62, 0.16);
    --accent-violet-ink: #BFAEFF;
    --accent-violet-soft: rgba(140, 111, 247, 0.2);

    --series-knowledge: #4E7FEF;
    --state-mastered: #4E7FEF;
    --state-fragile: #C2850F;
    --state-to_review: #DA4B4B;
    --state-unseen: #3A3E52;

    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.32);
    --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.22);
    --shadow-button: 0 6px 16px rgba(58, 103, 224, 0.4);
    --shadow-bar: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14151F;
  --surface: #1C1E2A;
  --surface-alt: #252838;
  --text-primary: #F1F2F8;
  --text-secondary: #A3A8BF;
  --border-subtle: #2E3145;
  --glass: rgba(30, 32, 46, 0.74);
  --glass-edge: rgba(255, 255, 255, 0.07);

  --accent-blue-ink: #8FB0FF;
  --accent-blue-soft: rgba(78, 127, 239, 0.2);
  --accent-green-ink: #6BE08F;
  --accent-green-soft: rgba(52, 200, 90, 0.16);
  --accent-red-ink: #FF8C9C;
  --accent-red-soft: rgba(240, 68, 90, 0.18);
  --accent-orange-ink: #FFC07A;
  --accent-orange-soft: rgba(255, 165, 62, 0.16);
  --accent-violet-ink: #BFAEFF;
  --accent-violet-soft: rgba(140, 111, 247, 0.2);

  --series-knowledge: #4E7FEF;
  --state-mastered: #4E7FEF;
  --state-fragile: #C2850F;
  --state-to_review: #DA4B4B;
  --state-unseen: #3A3E52;

  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.22);
  --shadow-button: 0 6px 16px rgba(58, 103, 224, 0.4);
  --shadow-bar: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* Gradient themes: components read --g (background) and --tint (shadow color). */
.grad-a, [data-tone="a"] { --g: var(--gradient-a); --tint: 140 111 247; }
.grad-b, [data-tone="b"] { --g: var(--gradient-b); --tint: 62 123 250; }
.grad-c, [data-tone="c"] { --g: var(--gradient-c); --tint: 255 92 108; }
.grad-d, [data-tone="d"] { --g: var(--gradient-d); --tint: 22 166 184; }
.grad-e, [data-tone="e"] { --g: var(--gradient-e); --tint: 91 92 240; }

/* --- Base ----------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 600px) {
  /* Wide screens: soft color glows around the app column. */
  body {
    background:
      radial-gradient(60rem 40rem at 8% -10%, rgba(255, 111, 165, 0.16), transparent 60%),
      radial-gradient(60rem 44rem at 100% 110%, rgba(62, 123, 250, 0.18), transparent 60%),
      var(--bg);
    background-attachment: fixed;
  }
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { line-height: 1.2; }
a { color: var(--accent-blue-ink); }
button { font: inherit; color: inherit; }
img, svg { display: block; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 2px 6px;
  border-radius: 7px;
  background: var(--surface-alt);
  overflow-wrap: anywhere;
}

kbd {
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border-subtle), 0 0 0 1px var(--border-subtle);
}

:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 3px;
  border-radius: 12px;
}

/* Components set their own display: the hidden attribute must still win. */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.emoji,
.empty-emoji,
.emoji-tile,
.mode-art > span,
.mode-option-emoji { font-family: var(--emoji); font-weight: 400; }

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Layout --------------------------------------------------------------- */

.app {
  position: relative; /* anchors the help button */
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) var(--gutter) calc(var(--tabbar-space) + 8px);
}

.has-hero .app,
.is-quiz .app { padding-top: 0; }

.is-welcome .app { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

.section { margin-top: 28px; }

.section-title {
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-lead {
  margin: -4px 0 12px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
}

.page-head { padding: 12px 52px 20px 4px; } /* the right side is the help button's */

/* "?" of every page: top right, above the page's own header. Sized by .icon-btn (44px),
   like every other icon button, the logout one of the home page included. */
.help-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 18px);
  right: var(--gutter);
  z-index: 5;
  font-size: 19px;
  font-weight: 900;
  text-decoration: none;
}

.help-btn:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }

/* On a coloured hero the button is made of glass, like the hero's own buttons. */
.has-hero .help-btn {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* Home only: its hero holds the avatar/name/logout row, taller than the plain heading of
   the other coloured heroes, so the help button sits a bit lower to stay level with it. */
.home-hero .help-btn { top: calc(env(safe-area-inset-top) + 34px); }

.has-hero .hero-bar { padding-right: 48px; }

.page-head h1 {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.page-sub {
  margin-top: 4px;
  color: var(--text-secondary);
  font-weight: 700;
}

.page-head-back {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 0;
}

.page-head-back h1 { font-size: 26px; }

.panel {
  padding: 20px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.panel-quiet {
  color: var(--text-secondary);
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius-button);
  font-size: 17px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.14s var(--ease-out), box-shadow 0.14s, filter 0.14s;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(180deg, #5C8CFF, #3A67E0);
  color: #FFFFFF;
  box-shadow: var(--shadow-button);
}

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
}

.btn-primary:disabled {
  background: var(--border-subtle);
  color: var(--text-secondary);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-soft {
  background: var(--accent-blue-soft);
  color: var(--accent-blue-ink);
}

@media (hover: hover) {
  .btn-soft:hover:not(:disabled) { filter: brightness(0.97); }
}

.btn-wide { width: 100%; }
.btn .icon { width: 20px; height: 20px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 0.14s var(--ease-out);
}

.icon-btn:active { transform: scale(0.94); }

.icon-btn-glass {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* Focus rings stay visible on colored surfaces. */
.hero :focus-visible,
.quiz-head :focus-visible { outline-color: #FFFFFF; }

/* --- Messages ------------------------------------------------------------- */

.toasts {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.has-hero .toasts,
.is-quiz .toasts { margin-top: calc(env(safe-area-inset-top) + 12px); }

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-row);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  font-size: 15px;
  font-weight: 700;
}

.toast-icon {
  width: 24px;
  height: 24px;
  padding: 4px;
  border-radius: 50%;
  background: var(--accent-green-soft);
  color: var(--accent-green-ink);
  stroke-width: 3;
}

.toast-error {
  background: var(--accent-red-soft);
  color: var(--accent-red-ink);
  box-shadow: none;
}

.toast-error .toast-icon {
  padding: 0;
  background: none;
  color: var(--accent-red-ink);
  stroke-width: 2.2;
}

.notice {
  padding: 12px 14px;
  border-radius: var(--radius-tile);
  font-size: 15px;
  font-weight: 700;
}

.notice-error {
  background: var(--accent-red-soft);
  color: var(--accent-red-ink);
}

.empty-state {
  padding: 28px 22px;
  text-align: center;
}

.empty-emoji {
  display: block;
  margin-bottom: 10px;
  font-size: 44px;
  line-height: 1;
}

.empty-state h1,
.empty-state h2 {
  margin-bottom: 6px;
  font-size: 20px;
  font-weight: 900;
}

.empty-state p {
  margin-bottom: 18px;
  color: var(--text-secondary);
}

.not-found { margin-top: 12vh; }


/* --- Tab bar -------------------------------------------------------------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  width: min(448px, calc(100% - 2 * var(--gutter)));
  padding: 6px;
  border-radius: 24px;
  background: var(--glass);
  box-shadow: var(--shadow-bar), inset 0 0 0 1px var(--glass-edge);
  transform: translateX(-50%);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  border-radius: 18px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s, transform 0.14s var(--ease-out);
}

.tab:active { transform: scale(0.95); }
.tab .icon { width: 24px; height: 24px; }
.tab span { text-align: center; line-height: 1.15; white-space: nowrap; }

.tab[aria-current="page"] {
  background: var(--accent-blue-soft);
  color: var(--accent-blue-ink);
}

/* --- Welcome, login, new profile ------------------------------------------ */

.welcome {
  padding-top: 36px;
  text-align: center;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 84px;
  height: 84px;
  border-radius: 20px;
  box-shadow: 0 14px 30px rgba(110, 100, 245, 0.4);
}

.brand-name {
  background: linear-gradient(120deg, #FF5C9A, #7C5CF5 50%, #3A67E0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1;
}

.welcome-title {
  margin: 30px 0 22px;
  font-size: 22px;
  font-weight: 800;
}

.admin-link {
  margin-top: 28px;
  font-size: 14px;
  font-weight: 700;
}
.admin-link a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text-secondary);
  text-decoration: none;
}
.admin-link a:hover { color: var(--accent-blue-ink); text-decoration: underline; }

.welcome-hint {
  margin-top: 20px;
  color: var(--text-secondary);
  font-weight: 600;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-radius: 20px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.14s var(--ease-out);
}

.profile-tile:active { transform: scale(0.95); }

.profile-name {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: var(--g, var(--gradient-brand));
  color: #FFFFFF;
  font-weight: 900;
  text-shadow: var(--on-color-shadow);
}

.avatar-xl {
  width: 84px;
  height: 84px;
  font-size: 34px;
  box-shadow: 0 10px 22px rgb(var(--tint, 62 123 250) / 0.35);
}

.avatar-md {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

.avatar-on-color { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding-right: 10px;
  color: var(--accent-blue-ink);
  font-weight: 800;
  text-decoration: none;
}

.auth {
  margin-top: 16px;
  padding-top: 28px;
}

.auth-avatar { margin: 0 auto 12px; display: grid; }

.auth-title {
  margin-bottom: 22px;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  letter-spacing: -0.02em;
}

.form {
  display: grid;
  gap: 18px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 800;
}

.field input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
  color: inherit;
  font: inherit;
  font-size: 17px;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.field input:focus {
  border-color: var(--accent-blue);
  background: var(--surface);
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-blue-soft);
}

.field input[aria-invalid="true"] { border-color: var(--accent-red); }

.field-help {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

.field-error {
  margin-top: 8px;
  color: var(--accent-red-ink);
  font-size: 15px;
  font-weight: 800;
}

/* --- Colored hero (home, result) ------------------------------------------ */

.hero {
  position: relative;
  margin: 0 calc(-1 * var(--gutter));
  padding: calc(env(safe-area-inset-top) + 20px) 20px 30px;
  overflow: hidden;
  border-radius: 0 0 32px 32px;
  background: var(--gradient-brand);
  color: #FFFFFF;
  isolation: isolate;
}

/* Soft translucent bubbles, echoing the layered shapes of the reference. */
.hero::before,
.hero::after,
.quiz-head::before,
.quiz-head::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.11);
  pointer-events: none;
}

.hero::before,
.quiz-head::before {
  width: 240px;
  height: 240px;
  top: -110px;
  right: -70px;
}

.hero::after,
.quiz-head::after {
  width: 180px;
  height: 180px;
  bottom: -110px;
  left: -40px;
}

.toasts + .hero { margin-top: 0; border-radius: 32px; }

@media (min-width: 520px) {
  .hero {
    margin: 16px 0 0;
    border-radius: 32px;
  }
}

.hero-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.greeting {
  flex: 1;
  min-width: 0;
  text-shadow: var(--on-color-shadow);
}

.greeting h1 {
  overflow: hidden;
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.greeting p {
  font-size: 15px;
  font-weight: 700;
  opacity: 0.92;
}

/* Home: the start button, always there. On the colored hero it takes the surface color. */
.btn-start {
  justify-content: flex-start;
  gap: 14px;
  min-height: 64px;
  margin-top: 24px;
  padding: 0 20px 0 10px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 10px 24px rgba(20, 40, 120, 0.25);
  font-size: 18px;
  font-weight: 900;
}

.resume + .btn-start,
.resume-form + .resume,
.resume-form + .btn-start,
.resume + .mode-grid,
.resume-form + .mode-grid,
.mode-grid + .btn-start { margin-top: 12px; }

.btn-start-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #5C8CFF, #3A67E0);
  color: #FFFFFF;
  box-shadow: var(--shadow-button);
}

.btn .btn-start-icon .icon { width: 20px; height: 20px; margin-left: 2px; }

/* No flashcard yet: greyed out like every disabled button, the reason written under it. */
.btn-start:disabled {
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
}

.btn-start:disabled .btn-start-icon {
  background: rgba(255, 255, 255, 0.24);
  color: rgba(255, 255, 255, 0.85);
  box-shadow: none;
}

.start-hint {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  text-shadow: var(--on-color-shadow);
}

.home-empty-state { margin-top: 24px; }

.resume {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  padding: 12px 12px 12px 14px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 10px 24px rgba(20, 40, 120, 0.25);
  text-decoration: none;
  transition: transform 0.14s var(--ease-out);
}

.resume:active { transform: scale(0.97); }

/* The paused session is resumed with a form (POST): the card is then a button. */
button.resume {
  width: 100%;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.resume-paused .resume-go { background: linear-gradient(180deg, #FFB547, #F08A24); }

.resume-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.resume-title { font-size: 16px; font-weight: 800; }

.resume-meta {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resume-go {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #5C8CFF, #3A67E0);
  color: #FFFFFF;
  box-shadow: var(--shadow-button);
}

.resume-go .icon { width: 20px; height: 20px; margin-left: 2px; }

/* --- Home: mode cards ----------------------------------------------------- */

.mode-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  min-height: 176px;
  padding: 16px;
  border-radius: var(--radius-card);
  background: var(--g);
  color: #FFFFFF;
  box-shadow: 0 12px 26px rgb(var(--tint) / 0.38);
  text-decoration: none;
  transition: transform 0.14s var(--ease-out);
}

.mode-card:active { transform: scale(0.97); }

.mode-art {
  display: flex;
  margin-bottom: auto;
}

.mode-art > span {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  font-size: 30px;
  line-height: 1;
}

.mode-art-stack > span {
  width: 48px;
  height: 48px;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.mode-art-stack > span + span { margin-left: -12px; }

.mode-name {
  margin-top: 18px;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-shadow: var(--on-color-shadow);
}

.mode-meta {
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  text-shadow: var(--on-color-shadow);
}

.mode-card-wide {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  min-height: 92px;
}

.mode-card-wide .mode-art { margin: 0; }

.mode-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.mode-card-wide .mode-name { margin-top: 0; }

.mode-go {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
}

.mode-go .icon { width: 20px; height: 20px; stroke-width: 2.8; }

/* Hardcore before any session: still reachable (the setup page explains), but visibly locked. */
.mode-card.is-locked {
  filter: grayscale(0.45);
  box-shadow: 0 8px 18px rgb(var(--tint) / 0.18);
}

.mode-card.is-locked .mode-go .icon { stroke-width: 2.4; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--surface);
  color: inherit;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  transition: transform 0.14s var(--ease-out);
}

.progress-row:active { transform: scale(0.97); }

.progress-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.progress-title { font-weight: 800; }

.progress-meta {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.row-chevron {
  color: var(--text-secondary);
  transition: transform 0.2s var(--ease-out);
}

/* --- Rings ---------------------------------------------------------------- */

.ring {
  --ring-size: 64px;
  --ring-stroke: 11;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--ring-size);
  height: var(--ring-size);
}

.ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ring circle {
  fill: none;
  stroke: var(--ring-color, var(--accent-blue));
  stroke-width: var(--ring-stroke);
  stroke-linecap: round;
}

/* The empty part of the ring is a light step of the same color. */
.ring-track { stroke-opacity: 0.16; }

.ring-center {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}

.ring-center .unit {
  margin-left: 1px;
  font-size: 0.62em;
  font-weight: 800;
}

.ring-fraction {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.ring-sm { --ring-size: 54px; --ring-stroke: 12; }
.ring-sm .ring-center { font-size: 14px; }
.ring-md { --ring-size: 58px; --ring-stroke: 11; }
.ring-md .ring-center { font-size: 15px; }
.ring-lg { --ring-size: 118px; --ring-stroke: 10; }
.ring-lg .ring-center { font-size: 28px; }
.ring-xl { --ring-size: 172px; --ring-stroke: 9; }

/* Gradients defined once in base.html; the track reuses them at low opacity. */
.ring-brand { --ring-color: url(#ring-brand); }
.ring-a { --ring-color: url(#ring-a); }
.ring-b { --ring-color: url(#ring-b); }
.ring-c { --ring-color: url(#ring-c); }
.ring-d { --ring-color: url(#ring-d); }
.ring-e { --ring-color: url(#ring-e); }
.ring-low { --ring-color: var(--accent-red); }
.ring-mid { --ring-color: var(--accent-orange); }
.ring-high { --ring-color: var(--accent-green); }
.ring-none { --ring-color: var(--text-secondary); }
.ring-glass { --ring-color: #FFFFFF; }
.ring-glass .ring-track { stroke-opacity: 0.28; }

.ring-big {
  font-size: 50px;
  text-shadow: var(--on-color-shadow);
}

@keyframes ring-fill {
  from { stroke-dasharray: 0 100; }
}

.ring-animated .ring-value { animation: ring-fill 1.1s var(--ease-out) 0.15s backwards; }

/* --- Session setup -------------------------------------------------------- */

.setup {
  display: grid;
  gap: 14px;
}

.setup-block {
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.block-title {
  display: block;
  margin: 0;
  padding: 0;
  font-size: 17px;
  font-weight: 800;
}

legend.block-title {
  float: left;
  width: 100%;
  margin-bottom: 12px;
}

.mode-picker {
  clear: both;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-option { display: block; cursor: pointer; }

.mode-option-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 100px;
  height: 100%;
  padding: 12px 6px;
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  transition: transform 0.14s var(--ease-out), box-shadow 0.15s;
}

.mode-option-emoji { font-size: 30px; line-height: 1; }

.mode-option:active .mode-option-body { transform: scale(0.96); }

.mode-option input:checked + .mode-option-body {
  background: var(--g);
  color: #FFFFFF;
  box-shadow: 0 8px 18px rgb(var(--tint) / 0.35);
  text-shadow: var(--on-color-shadow);
}

.mode-option input:focus-visible + .mode-option-body,
.chip input:focus-visible + .chip-body {
  outline: 3px solid var(--accent-blue);
  outline-offset: 3px;
}

.setup-help {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 14.5px;
  font-weight: 600;
}

.setup-help:empty { display: none; }

.chips {
  clear: both;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chip { display: block; min-width: 0; cursor: pointer; }

/* Subject tile: emoji and card count on top, the name below at full width. */
.chip-body {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "emoji count" "name name";
  align-items: center;
  gap: 6px;
  height: 100%;
  min-height: 80px;
  padding: 12px;
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
  transition: transform 0.14s var(--ease-out), opacity 0.15s;
}

.chip:active .chip-body { transform: scale(0.96); }

.chip-emoji { grid-area: emoji; font-size: 24px; line-height: 1; }

.chip-name {
  grid-area: name;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.chip-count {
  grid-area: count;
  min-width: 30px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.chip input:checked + .chip-body {
  background: var(--g, var(--gradient-brand));
  color: #FFFFFF;
  box-shadow: 0 8px 18px rgb(var(--tint, 62 123 250) / 0.35);
  text-shadow: var(--on-color-shadow);
}

.chip input:checked + .chip-body .chip-count {
  background: rgba(255, 255, 255, 0.28);
  color: #FFFFFF;
}

/* Hardcore: a subject never trained has nothing to offer yet. */
.chip.is-empty .chip-body { opacity: 0.55; }
.chip.is-empty input:checked + .chip-body { opacity: 1; }

/* "Réviser par chapitre": a switch, then the list of chapters it reveals. */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  cursor: pointer;
}

.toggle-text { flex: 1; min-width: 0; }
.toggle-text .setup-help { margin-top: 2px; }

.toggle-track {
  flex: none;
  position: relative;
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: var(--border-subtle);
  transition: background 0.16s var(--ease-out);
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s var(--ease-out);
}

.toggle-input:checked ~ .toggle-track { background: var(--accent-green); }
.toggle-input:checked ~ .toggle-track .toggle-knob { transform: translateX(20px); }
.toggle-input:focus-visible ~ .toggle-track { outline: 3px solid var(--accent-blue); outline-offset: 3px; }

.chapter-picker { margin-top: 16px; }

.chapter-actions { display: flex; gap: 8px; margin-bottom: 12px; }

/* Tall lists (a subject can hold dozens of chapters) scroll inside the card. */
.chapter-scroll {
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.chapter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chapter-group:first-child { margin-top: 0; }

.chapter { display: block; cursor: pointer; }
.chapter + .chapter { margin-top: 6px; }

.chapter-body {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: var(--radius-row);
  background: var(--surface-alt);
  transition: background 0.14s, transform 0.14s var(--ease-out);
}

.chapter:active .chapter-body { transform: scale(0.98); }

.chapter-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--border-subtle);
  color: transparent;
}

.chapter-check .icon { width: 16px; height: 16px; stroke-width: 3; }

.chapter-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chapter-count {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.chapter input:checked + .chapter-body { background: var(--accent-blue-soft); }
.chapter input:checked + .chapter-body .chapter-check {
  background: var(--accent-blue);
  box-shadow: none;
  color: #FFFFFF;
}
.chapter input:focus-visible + .chapter-body { outline: 3px solid var(--accent-blue); outline-offset: 2px; }
.chapter.is-empty .chapter-body { opacity: 0.55; }
.chapter.is-empty input:checked + .chapter-body { opacity: 1; }

.slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.slider-value {
  color: var(--accent-blue-ink);
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  --fill: 50%;
  width: 100%;
  height: 44px;
  margin: 4px 0 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6A95FF, #3A67E0) 0 / var(--fill) 100% no-repeat, var(--border-subtle);
}

input[type="range"]::-webkit-slider-thumb {
  width: 30px;
  height: 30px;
  margin-top: -10px;
  border: 5px solid var(--accent-blue);
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 3px 10px rgba(40, 70, 170, 0.35);
  -webkit-appearance: none;
  appearance: none;
  transition: transform 0.14s var(--ease-out);
}

input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }

input[type="range"]::-moz-range-track {
  height: 10px;
  border-radius: 999px;
  background: var(--border-subtle);
}

input[type="range"]::-moz-range-progress {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6A95FF, #3A67E0);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 5px solid var(--accent-blue);
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 3px 10px rgba(40, 70, 170, 0.35);
}

input[type="range"]:focus-visible { outline-offset: 0; }

input[type="range"]:disabled { cursor: not-allowed; opacity: 0.45; }

.slider-scale {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.btn-launch { margin-top: 4px; }

/* --- Quiz ----------------------------------------------------------------- */

.is-quiz .app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 0;
}

.quiz {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.quiz-head {
  position: relative;
  margin: 0 calc(-1 * var(--gutter));
  padding: calc(env(safe-area-inset-top) + 14px) 16px 66px;
  overflow: hidden;
  border-radius: 0 0 32px 32px;
  background: var(--g, var(--gradient-brand));
  color: #FFFFFF;
  isolation: isolate;
  transition: background 0.3s;
}

@media (min-width: 520px) {
  .quiz-head {
    margin: 16px 0 0;
    border-radius: 32px;
  }
}

.quiz-bar {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.quiz-actions { display: flex; gap: 8px; }

.quiz-label {
  overflow: hidden;
  font-size: 17px;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: var(--on-color-shadow);
  white-space: nowrap;
}

.quiz-progress {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
}

.quiz-progress svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.quiz-progress circle {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.quiz-progress-track { stroke: rgba(255, 255, 255, 0.3); }

.quiz-progress-value {
  stroke: #FFFFFF;
  transition: stroke-dasharray 0.5s var(--ease-out);
}

.quiz-progress-text {
  position: relative;
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: -0.03em;
  text-shadow: var(--on-color-shadow);
}

.question-card {
  position: relative;
  margin-top: -46px;
  padding: 18px 20px 20px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 12px;
}

.kind-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.kind-badge::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

.kind-badge.kind-single {
  background: var(--accent-blue-soft);
  color: var(--accent-blue-ink);
}

.kind-badge.kind-multiple {
  background: var(--accent-violet-soft);
  color: var(--accent-violet-ink);
}

.kind-badge.kind-multiple::before { border-radius: 3px; }

.subject-tag {
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 800;
}

/* Stopwatch of a timed session, pushed to the right of the question's meta row. */
.chrono {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.chrono[hidden] { display: none; }

/* Result page of a timed session. */
.timing-summary { margin: 0 0 16px; padding: 16px; }

.timing-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.timing-figures p {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
}

.timing-value { font-size: 24px; font-weight: 900; }
.timing-label { color: var(--text-secondary); font-size: 13px; font-weight: 700; }

.timing-slowest {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
}

.timing-question { display: block; margin-top: 4px; color: var(--text-primary); font-weight: 600; }
.timing-question strong { white-space: nowrap; }

.stem {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.38;
  letter-spacing: -0.005em;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.stem:focus { outline: none; }

.options {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 11px 12px;
  border: 2px solid transparent;
  border-radius: var(--radius-row);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.38;
  text-align: left;
  transition: transform 0.14s var(--ease-out), background-color 0.15s, border-color 0.15s, opacity 0.2s;
}

button.option { cursor: pointer; }
button.option[aria-disabled="true"] { cursor: default; }
button.option:active:not([aria-disabled="true"]) { transform: scale(0.98); }

.option-letter {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 2px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 900;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

/* Round bubbles for QCU (one answer), square ones for QCM (several). */
.kind-single .option-letter { border-radius: 50%; }

.option-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.option[aria-checked="true"] {
  border-color: var(--accent-blue);
  background: var(--accent-blue-soft);
}

.option[aria-checked="true"] .option-letter {
  border-color: var(--accent-blue);
  background: var(--accent-blue);
  color: #FFFFFF;
}

.option.is-correct {
  border-color: var(--accent-green);
  background: var(--accent-green-soft);
}

.option.is-wrong {
  border-color: var(--accent-red);
  background: var(--accent-red-soft);
}

.option.is-missed {
  border: 2px dashed var(--accent-green);
  background: var(--surface);
}

.option.is-neutral {
  box-shadow: none;
  opacity: 0.55;
}

.option.is-correct .option-letter {
  border-color: var(--accent-green-strong);
  background: var(--accent-green-strong);
  color: #FFFFFF;
}

.option.is-wrong .option-letter {
  border-color: var(--accent-red);
  background: var(--accent-red);
  color: #FFFFFF;
}

.option.is-missed .option-letter {
  border-color: var(--accent-green);
  background: var(--accent-green-soft);
  color: var(--accent-green-ink);
}

.option-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  color: #FFFFFF;
}

.option-mark .icon { width: 17px; height: 17px; stroke-width: 3.2; }
.is-correct .option-mark { background: var(--accent-green-strong); }
.is-wrong .option-mark { background: var(--accent-red); }

/* Tag of a missed right answer: under the option text, so long options keep their width. */
.option-tag {
  display: table;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-green-soft);
  color: var(--accent-green-ink);
  font-size: 12px;
  font-weight: 900;
}

@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
}

.options.is-animated .option-mark,
.options.is-animated .option-tag { animation: pop 0.32s var(--ease-spring); }

/* Next question: the card slides in from the right, like turning a page. */
@keyframes enter {
  from { transform: translateX(28px); opacity: 0; }
}

.question-card.is-entering { animation: enter 0.3s var(--ease-out); }
.options.is-entering { animation: enter 0.3s var(--ease-out) 0.04s backwards; }

/* Sticky, not fixed: the footer keeps its place in the flow, after the options, so scrolling
   to the end always shows the last option above it. quiz.js keeps its height in
   --quiz-footer-height: browser scrolls (focus, keyboard) stop above it too. */
:root:has(.is-quiz) { scroll-padding-bottom: calc(var(--quiz-footer-height, 0px) + 12px); }

.quiz-footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin: auto calc(-1 * var(--gutter)) 0;
  padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--glass);
  box-shadow: 0 -8px 24px rgba(70, 90, 160, 0.1);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.options { margin-bottom: 20px; }

.feedback {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  animation: feedback-in 0.34s var(--ease-spring);
}

@keyframes feedback-in {
  from { transform: translateY(16px); opacity: 0; }
}

.feedback.is-right { background: var(--accent-green-soft); }
.feedback.is-wrong { background: var(--accent-red-soft); }

.feedback-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  color: #FFFFFF;
}

.feedback-icon .icon { width: 22px; height: 22px; stroke-width: 3.2; }
.is-right .feedback-icon { background: var(--accent-green-strong); }
.is-wrong .feedback-icon { background: var(--accent-red); }

.feedback-text { min-width: 0; padding-top: 1px; }

.feedback-title {
  font-size: 19px;
  font-weight: 900;
  line-height: 1.25;
}

.is-right .feedback-title { color: var(--accent-green-ink); }
.is-wrong .feedback-title { color: var(--accent-red-ink); }

.feedback-source {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.feedback-source:empty { display: none; }
.feedback-source span { display: block; }
.feedback-source span:first-child { color: var(--text-primary); }

.quiz-footer .notice { margin-bottom: 12px; }

.notice-info {
  background: var(--accent-orange-soft);
  color: var(--accent-orange-ink);
}

/* "Je n'ai pas révisé ce cours": a quiet second action under "Valider". */
.btn-skip {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-tile);
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.btn-skip:hover { color: var(--accent-blue-ink); }
.btn-skip:active { transform: scale(0.98); }
.btn-skip:disabled { opacity: 0.5; cursor: default; }
.btn-skip:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }

@media (min-width: 520px) {
  /* Wide screens: the footer floats inside the app column instead of touching the edges. */
  .quiz-footer {
    bottom: 16px;
    margin: auto 0 16px;
    padding: 14px;
    border-radius: 24px;
    box-shadow: var(--shadow-bar), inset 0 0 0 1px var(--glass-edge);
  }
}

.shortcuts { display: none; }

@media (hover: hover) and (pointer: fine) {
  .shortcuts {
    display: block;
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
  }
}

/* --- Result --------------------------------------------------------------- */

.hero-result[data-tone] { background: var(--g); }

.hero-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 30px;
  text-align: center;
}

.hero-kicker {
  margin-bottom: 18px;
  font-weight: 800;
  text-shadow: var(--on-color-shadow);
  opacity: 0.95;
}

.result-cheer {
  margin-top: 18px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.015em;
  text-shadow: var(--on-color-shadow);
}

.result-count {
  margin-top: 4px;
  font-weight: 700;
  text-shadow: var(--on-color-shadow);
}

.result-actions { margin-top: 18px; }

.review-list,
.review-sections,
.answer-list,
.subject-scores,
.catalog,
.catalog-documents,
.card-list,
.ranking,
.import-errors-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-list { display: grid; gap: 12px; }

.review-doc {
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.review-doc-name {
  margin-bottom: 6px;
  font-weight: 800;
}

.review-sections li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
}

.count-pill {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-red-soft);
  color: var(--accent-red-ink);
  font-size: 12.5px;
  font-weight: 900;
  white-space: nowrap;
}

.answer-list { display: grid; gap: 10px; }

.answer {
  border-radius: var(--radius-row);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

summary {
  list-style: none;
  cursor: pointer;
}

summary::-webkit-details-marker { display: none; }

details[open] > summary .row-chevron { transform: rotate(90deg); }

.answer > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 12px 14px;
  border-radius: var(--radius-row);
}

.answer-status {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  color: #FFFFFF;
}

.answer-status .icon { width: 18px; height: 18px; stroke-width: 3.2; }
.answer.is-right .answer-status { background: var(--accent-green-strong); }
.answer.is-wrong .answer-status { background: var(--accent-red); }

.answer-head {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.answer-stem {
  display: -webkit-box;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

details[open] .answer-stem { display: block; }

.answer-meta {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.answer-body { padding: 0 12px 14px; }

.options-static {
  gap: 8px;
  margin: 0;
}

.options-static .option {
  min-height: 0;
  padding: 9px 10px;
  background: var(--surface-alt);
  box-shadow: none;
  font-size: 15px;
}

.options-static .option.is-correct { background: var(--accent-green-soft); }
.options-static .option.is-wrong { background: var(--accent-red-soft); }
.options-static .option.is-missed { background: var(--surface); }
.options-static .option-letter { width: 30px; height: 30px; font-size: 14px; }

.answer-source {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-tile);
  background: var(--accent-red-soft);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
}

.answer-source span { display: block; }
.answer-source-doc { color: var(--text-primary); }

.answer-stats {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 700;
}

/* --- Scores --------------------------------------------------------------- */

.hero-heading {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-shadow: var(--on-color-shadow);
}

.hero-sub {
  margin-top: 2px;
  font-weight: 700;
  text-shadow: var(--on-color-shadow);
  opacity: 0.92;
}

.hero-scores { padding-bottom: 30px; }

.overview-rings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
  text-align: center;
}

.hero .ring-caption { text-shadow: var(--on-color-shadow); }
.hero .ring-detail { color: rgba(255, 255, 255, 0.9); text-shadow: var(--on-color-shadow); }

.overview-start { margin-top: 16px; }

.overview-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: inherit;
  text-decoration: none;
  transition: transform 0.14s var(--ease-out);
}

a.overview-ring:active { transform: scale(0.97); }

/* "Vue rapide" on the home page: the rings sit in their own panel, not on the hero. */
.panel.overview-rings { margin-top: 0; }

.ring-caption {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 900;
}

.ring-detail {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 700;
}

.overview-hint {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.subject-scores { display: grid; gap: 12px; }

.subject-score {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.subject-score-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.emoji-tile {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: var(--radius-tile);
  background: var(--g, var(--gradient-brand));
  color: #FFFFFF;
  box-shadow: 0 6px 14px rgb(var(--tint, 62 123 250) / 0.3);
  font-size: 24px;
  line-height: 1;
}

.subject-score-text { min-width: 0; }

.subject-score-text h3 {
  font-size: 17px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.subject-score-text p {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
}

.subject-rings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-ring {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mini-ring-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mini-ring .ring-caption {
  margin: 0;
  font-size: 14.5px;
  font-weight: 900;
}

.mini-ring .ring-detail {
  margin: 0;
  font-size: 13px;
}

.disclosure,
.subject-start { grid-column: 1 / -1; }

/* A soft tinted row instead of a divider line: the app has no ruled lines. */
.disclosure > summary,
.subject-start {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 46px;
  padding: 0 12px 0 14px;
  border-radius: var(--radius-tile);
  background: var(--accent-blue-soft);
  color: var(--accent-blue-ink);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.14s var(--ease-out);
}

.disclosure > summary:active,
.subject-start:active { transform: scale(0.98); }

.disclosure > summary .row-chevron { color: currentColor; }

.subject-start .icon { width: 20px; height: 20px; }

.ranking-title {
  margin: 12px 0 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 800;
}

/* Scores page: one row per chapter, tappable to revise that chapter alone. */
.chapter-scores { display: grid; gap: 6px; margin-top: 12px; padding: 0; list-style: none; }

.chapter-score {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 8px 8px 12px;
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
  color: inherit;
  text-decoration: none;
  transition: transform 0.14s var(--ease-out);
}

.chapter-score:active { transform: scale(0.98); }

.chapter-score-text { flex: 1; min-width: 0; }

.chapter-score-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chapter-score-meta {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.chapter-score .row-chevron { flex: none; color: var(--text-secondary); }

.ranking { display: grid; gap: 8px; }

.ranking li {
  padding: 10px 12px;
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
}

.ranking-stem {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
}

/* --- Mes cours ------------------------------------------------------------ */

.import-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.import-head .icon { width: 24px; height: 24px; }
.import-title { font-size: 17px; font-weight: 900; }

.import-intro {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
}

.import-note {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.import-panel + .empty-state { margin-top: 16px; }

/* What a chapter holds, by kind of support (flashcards for now). */
.support-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }

.support-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-blue-soft);
  color: var(--accent-blue-ink);
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
}

/* Upload: the label is the button, the file input under it stays reachable by keyboard. */
.upload-button {
  -webkit-user-select: none;
  user-select: none;
}

.upload-input:focus-visible + .upload-button {
  outline: 3px solid var(--accent-blue);
  outline-offset: 3px;
}

.upload-button.is-busy {
  background: var(--border-subtle);
  color: var(--text-secondary);
  box-shadow: none;
  cursor: progress;
  pointer-events: none;
}

.upload-button .spinner { display: none; }
.upload-button.is-busy .spinner { display: block; }
.upload-button.is-busy .icon { display: none; }

.spinner {
  width: 20px;
  height: 20px;
  flex: none;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.upload-help {
  margin-top: 10px;
  padding: 0 4px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.upload-submit { margin-top: 12px; }

.import-errors {
  margin-top: 16px;
  background: var(--accent-red-soft);
  box-shadow: none;
}

.import-errors-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-red-ink);
  font-size: 17px;
  font-weight: 900;
}

.import-errors-help {
  margin-top: 6px;
  font-size: 14.5px;
  font-weight: 600;
}

.import-errors-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.import-errors-list li {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.catalog { display: grid; gap: 12px; }

.catalog-subject {
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.catalog-subject > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 14px 16px;
  border-radius: 22px;
}

.catalog-head {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.catalog-name {
  font-size: 17px;
  font-weight: 900;
}

.catalog-meta {
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 700;
}

.catalog-documents {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.catalog-document {
  border-radius: var(--radius-row);
  background: var(--surface-alt);
}

.catalog-document > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 12px 12px 12px 14px;
  border-radius: var(--radius-row);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
}

.catalog-document-name {
  flex: 1;
  min-width: 0;
}

.catalog-document .count-pill {
  background: var(--surface);
  color: var(--text-secondary);
}

.card-list {
  display: grid;
  gap: 8px;
  padding: 0 8px 8px;
}

.card-row {
  padding: 12px 14px;
  border-radius: var(--radius-tile);
  background: var(--surface);
}

.card-stem {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  white-space: pre-line;
}

.card-meta,
.ranking-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.card-section {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

/* --- Pills ---------------------------------------------------------------- */

.kind-pill,
.rate-pill {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.kind-pill.kind-single { background: var(--accent-blue-soft); color: var(--accent-blue-ink); }
.kind-pill.kind-multiple { background: var(--accent-violet-soft); color: var(--accent-violet-ink); }

.rate-pill.rate-low { background: var(--accent-red-soft); color: var(--accent-red-ink); }
.rate-pill.rate-mid { background: var(--accent-orange-soft); color: var(--accent-orange-ink); }
.rate-pill.rate-high { background: var(--accent-green-soft); color: var(--accent-green-ink); }
.rate-pill.rate-none { background: var(--surface-alt); color: var(--text-secondary); }

/* --- Motion preferences --------------------------------------------------- */

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


/* --- Progression ------------------------------------------------------------------ */

/* Subject filter: one row of links above everything it scopes. */
.scope-filter {
  display: flex;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter)) 16px;
  padding: 2px var(--gutter) 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.scope-filter::-webkit-scrollbar { display: none; }

.scope-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.scope-chip[aria-current="page"] {
  background: var(--accent-blue);
  color: #FFFFFF;
  box-shadow: var(--shadow-button);
}

.scope-chip:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }

/* The level: one hero figure, then the two numbers it is made of. */
.knowledge-hero { padding: 22px 20px 18px; }

.knowledge-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 800;
}

.knowledge-value {
  margin-top: 2px;
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
}

.knowledge-unit { margin-left: 4px; font-size: 32px; letter-spacing: 0; }

.trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
}

.trend-up { background: var(--accent-green-soft); color: var(--accent-green-ink); }
.trend-down { background: var(--accent-red-soft); color: var(--accent-red-ink); }
.trend-flat { background: var(--surface-alt); color: var(--text-secondary); }

.knowledge-parts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  margin-top: 18px;
}

.knowledge-part {
  padding: 12px;
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
}

.part-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
}

.part-value { margin-top: 2px; font-size: 26px; font-weight: 900; }

.part-detail {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.part-operator {
  align-self: center;
  color: var(--text-secondary);
  font-size: 22px;
  font-weight: 800;
}

/* The curve. */
.chart-card { margin-top: 16px; padding: 18px 16px 14px; }

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 14px;
}

.chart-title { font-size: 17px; font-weight: 800; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 0;
  list-style: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }

.legend-line {
  display: inline-block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
}

.legend-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.key-knowledge { background: var(--series-knowledge); }
.key-coverage { background: var(--series-coverage); }

.chart {
  position: relative;
  padding: 0 34px 0 38px; /* room for the y ticks (left) and the end labels (right) */
  outline: none;
  touch-action: pan-y; /* a horizontal drag reads the curve, a vertical one scrolls the page */
}

.chart:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 4px; border-radius: 8px; }

.chart-plot { position: relative; height: 190px; }

.chart-grid {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border-subtle);
}

.chart-grid span {
  position: absolute;
  right: 100%;
  margin-right: 8px;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-marks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.line {
  fill: none;
  stroke-width: 2px;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.line-knowledge { stroke: var(--series-knowledge); }
.line-coverage { stroke: var(--series-coverage); }

.chart-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface); /* surface ring: legible where lines cross */
  pointer-events: none;
}

.dot-knowledge { background: var(--series-knowledge); }
.dot-coverage { background: var(--series-coverage); }

.end-label {
  position: absolute;
  left: 100%;
  margin-left: 9px;
  transform: translateY(-50%);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.chart-crosshair {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--text-secondary);
  opacity: 0.5;
  pointer-events: none;
}

.chart.is-reading .is-end { opacity: 0; }

.chart-tooltip {
  position: absolute;
  top: 0;
  z-index: 2;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-bar), inset 0 0 0 1px var(--border-subtle);
  font-size: 13px;
  pointer-events: none;
}

.tooltip-day { color: var(--text-secondary); font-weight: 800; }

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.tooltip-row strong { font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }


.chart-x { position: relative; height: 26px; margin-top: 6px; }

.chart-x span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chart-x .is-first { transform: none; }
.chart-x .is-last { transform: translateX(-100%); }

.chart-empty {
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-weight: 700;
}

.chart-table { margin-top: 12px; }
.table-scroll { max-height: 260px; margin-top: 8px; overflow-y: auto; }

.progress-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.progress-table th,
.progress-table td { padding: 8px 6px; text-align: left; }
.progress-table thead th { color: var(--text-secondary); font-size: 12px; font-weight: 800; }
.progress-table tbody tr:nth-child(odd) { background: var(--surface-alt); }
.progress-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Priorities. */
.priority-list { display: grid; gap: 8px; padding: 0; list-style: none; }

.priority {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: var(--radius-row);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: inherit;
  text-decoration: none;
  transition: transform 0.14s var(--ease-out);
}

.priority:active { transform: scale(0.98); }
.priority:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }

.priority-rank {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-red-soft);
  color: var(--accent-red-ink);
  font-weight: 900;
}

.priority-text { flex: 1; min-width: 0; }
.priority-name { display: block; font-size: 15px; font-weight: 800; overflow-wrap: anywhere; }

.priority-figure { white-space: nowrap; }

.priority-meta {
  display: block;
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.priority-go {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--accent-blue-ink);
  font-size: 14px;
  font-weight: 800;
}

.priority-go .icon { width: 18px; height: 18px; }

/* Chapters. */
.chapter-levels { padding: 0; }
.chapter-levels + .chapter-levels { margin-top: 12px; }

.chapter-levels-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 14px 0 16px;
  list-style: none;
  cursor: pointer;
}

.chapter-levels-summary::-webkit-details-marker { display: none; }
.chapter-levels-summary:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: -3px; border-radius: var(--radius-card); }
.chapter-levels[open] > .chapter-levels-summary .row-chevron { transform: rotate(90deg); }
.chapter-levels-summary .row-chevron { flex: none; color: var(--text-secondary); transition: transform 0.15s; }

.chapter-levels-title {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 17px;
  font-weight: 800;
}

.chapter-levels-value { font-size: 16px; font-weight: 900; }
.chapter-level-list { display: grid; gap: 6px; padding: 0 16px 16px; list-style: none; }

.chapter-level {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
}

.fold-tools { display: inline-flex; gap: 14px; }

.chapter-level-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.chapter-level-name { min-width: 0; font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.chapter-level-value { flex: none; font-size: 17px; font-weight: 900; }

.chapter-level-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chapter-level-parts {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.spark { flex: none; width: 72px; height: 22px; overflow: visible; }

.spark polyline {
  fill: none;
  stroke: var(--series-knowledge);
  stroke-width: 1.5px;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* How it is computed. */
.explain { margin-top: 24px; padding: 0; }

.explain > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.explain > summary::-webkit-details-marker { display: none; }
.explain[open] > summary .row-chevron { transform: rotate(90deg); }
.explain-body { padding: 0 16px 16px; color: var(--text-secondary); font-size: 15px; line-height: 1.55; }
.explain-body p + dl, .explain-terms + p { margin-top: 12px; }
.explain-terms dt { margin-top: 10px; color: var(--text-primary); font-weight: 800; }
.explain-terms dd { margin: 2px 0 0; }


/* --- Ma progression: what is known and what is not -------------------------------- */

.progress-filters { margin-bottom: 16px; }
.progress-filters .scope-filter { margin-bottom: 8px; }

/* "Tenir compte du temps de réponse": a switch made of a link (it reloads the page). */
.weight-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}

.weight-toggle[aria-checked="true"] .toggle-track { background: var(--accent-green); }
.weight-toggle[aria-checked="true"] .toggle-knob { transform: translateX(20px); }
.weight-toggle:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 3px; border-radius: 12px; }

.weight-note { color: var(--text-secondary); font-size: 13px; font-weight: 600; }

.hero-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* The states of the cards. */
.known-card { margin-top: 16px; padding: 18px 16px; }

.state-bar {
  display: flex;
  gap: 2px; /* surface gap between segments */
  height: 8px;
  margin: 8px 0 6px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--state-unseen);
}

.state-bar.is-big { height: 18px; margin: 14px 0 12px; border-radius: 6px; }

.state-segment { display: block; flex-basis: 0; min-width: 3px; }

.state-mastered { background: var(--state-mastered); }
.state-fragile { background: var(--state-fragile); }
.state-to_review { background: var(--state-to_review); }
.state-unseen { background: var(--state-unseen); }

.state-key {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.state-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  padding: 0;
  list-style: none;
}

.state-legend li { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.state-legend .state-key { align-self: center; }
.state-count { font-size: 18px; font-weight: 900; }
.state-name { min-width: 0; color: var(--text-secondary); font-size: 14px; font-weight: 700; }
.state-share { margin-left: auto; color: var(--text-secondary); font-size: 13px; font-weight: 700; }

.known-summary {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}

.known-summary strong { color: var(--text-primary); }

/* Stacked areas: each layer separated from the next by a surface-coloured stroke. */
.area {
  stroke: var(--surface);
  stroke-width: 2px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.area-mastered { fill: var(--state-mastered); }
.area-fragile { fill: var(--state-fragile); }
.area-to_review { fill: var(--state-to_review); }
.area-unseen { fill: var(--state-unseen); }

/* Columns: at most 24px wide, rounded at the top, square on the baseline. */
.bar {
  position: absolute;
  bottom: 0;
  width: min(24px, calc(var(--band) - 2px));
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: var(--series-knowledge);
  transform: translateX(-50%);
  transition: filter 0.12s;
}

.bar.is-active { filter: brightness(1.25) saturate(1.1); box-shadow: 0 0 0 2px var(--surface); }

.chart-bars .chart-plot { height: 140px; }
.chart-bars .chart-grid:first-child { border-top-color: var(--text-secondary); opacity: 0.6; }

.tooltip-name { color: var(--text-secondary); font-weight: 700; }

.chart-card .chart-card { margin-top: 0; }
.section .chart-card { margin-top: 12px; }
.chart-card > .chart-title:first-child { margin-bottom: 12px; }

/* Stat tiles. */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border-radius: var(--radius-tile);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.stat-value { font-size: 24px; font-weight: 900; line-height: 1.15; }
.stat-label { margin-top: 2px; color: var(--text-secondary); font-size: 13px; font-weight: 700; line-height: 1.3; }

/* Pace. */
.pace-card { padding: 16px; }
.pace-main { font-size: 16px; font-weight: 700; line-height: 1.5; }
.pace-eta { margin-top: 8px; color: var(--text-secondary); font-size: 15px; font-weight: 600; line-height: 1.5; }
.pace-eta strong { color: var(--text-primary); }

.priority-rank.is-refresh { background: var(--accent-blue-soft); color: var(--accent-blue-ink); }

.chapter-legend { margin-bottom: 12px; }


/* --- Dialogs -------------------------------------------------------------- */

.dialog {
  width: min(420px, calc(100% - 2 * var(--gutter)));
  max-height: calc(100% - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-bar);
}

.dialog::backdrop { background: rgba(20, 21, 31, 0.45); }
.dialog-body { display: grid; gap: 12px; padding: 22px 20px 18px; }
.dialog-title { font-size: 20px; font-weight: 900; }
.dialog-text { color: var(--text-secondary); font-size: 15px; font-weight: 600; line-height: 1.45; }

.dialog-files {
  display: grid;
  gap: 4px;
  max-height: 160px;
  margin: 0;
  padding: 10px 12px;
  overflow-y: auto;
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
  list-style: none;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-actions .btn { flex: 1 1 auto; }
.dialog-actions > form { display: flex; flex: 1 1 auto; }
.dialog-choices { display: grid; gap: 8px; }
.dialog-choice { width: 100%; text-align: left; }
.dialog-choice-hint { display: block; margin-top: 2px; font-size: 13px; font-weight: 600; opacity: 0.85; }


/* --- History -------------------------------------------------------------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head .section-title { margin-bottom: 0; }

.section-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  color: var(--accent-blue-ink);
  font-size: 14.5px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.section-link .icon { width: 18px; height: 18px; }

.history-list { display: grid; gap: 8px; padding: 0; list-style: none; }

.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 10px 10px 12px;
  border-radius: var(--radius-row);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: inherit;
  text-decoration: none;
  transition: transform 0.14s var(--ease-out);
}

.history-row:active { transform: scale(0.98); }
.history-row:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }
.history-score { flex: none; min-width: 56px; text-align: center; font-size: 15px; }
.history-text { flex: 1; min-width: 0; }
.history-label { display: block; font-size: 15px; font-weight: 800; overflow-wrap: anywhere; }

.history-meta {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

.history-tag { color: var(--accent-orange-ink); font-weight: 800; }
.history-row .row-chevron { flex: none; color: var(--text-secondary); }
.result-early { margin: 0 0 16px; }

/* A button that looks like a link (secondary actions inside a block). */
.link-btn {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-blue-ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
}

.link-btn:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; border-radius: 8px; }

.subject-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 10px;
}

.subject-tools .setup-help { margin-top: 0; }

.dialog-choice.is-danger { color: var(--accent-red-ink); }

/* --- Mon espace -------------------------------------------------------------- */

.space-head { display: flex; align-items: center; gap: 14px; }

.space-nav {
  display: flex;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter)) 16px;
  padding: 2px var(--gutter) 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.space-nav::-webkit-scrollbar { display: none; }

.space-nav a {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}

.setting-card { padding: 18px 16px; scroll-margin-top: 16px; }
.setting-card + .setting-card { margin-top: 16px; }
.setting-card-title { font-size: 19px; font-weight: 900; }

.setting-intro {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

.setting-form { display: grid; gap: 16px; margin-top: 14px; }

.setting-group {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.setting { min-width: 0; margin: 0; padding: 0; border: 0; }
.setting-label { display: block; font-size: 16px; font-weight: 800; }

.setting-help {
  display: block;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.setting-default { white-space: nowrap; }
.setting-input { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.setting-input input,
.text-input {
  width: 100%;
  max-width: 140px;
  min-height: 48px;
  padding: 0 14px;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
  color: inherit;
  font: inherit;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.text-input { max-width: none; margin-top: 8px; letter-spacing: 0.06em; }

.setting-input input:focus,
.text-input:focus {
  border-color: var(--accent-blue);
  background: var(--surface);
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-blue-soft);
}

.setting-unit { color: var(--text-secondary); font-size: 15px; font-weight: 800; }

/* A row of choices, one picked: theme, language, recency. */
.segmented {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  margin-top: 8px;
  padding: 4px;
  border-radius: var(--radius-tile);
  background: var(--surface-alt);
}

.segment { display: block; cursor: pointer; }

.segment span {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 0 6px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 14.5px;
  font-weight: 800;
  text-align: center;
}

.segment input:checked + span { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-soft); }
.segment input:focus-visible + span { outline: 3px solid var(--accent-blue); outline-offset: 2px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 6px;
  font-size: 16px;
  font-weight: 700;
}

.check-row input { width: 22px; height: 22px; accent-color: var(--accent-blue); }
.setting-reset { margin-top: 12px; }

.btn-danger {
  background: linear-gradient(180deg, #FF6275, #D92B45);
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(217, 43, 69, 0.28);
}

.danger-card .setting-group { color: var(--accent-red-ink); }
.setting-help-link { margin-top: 10px; }

.help-glyph {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-blue-soft);
  color: var(--accent-blue-ink);
  font-weight: 900;
}

/* Hidden by settings.js, which saves the appearance as soon as it changes. */
.setting-form.is-autosaved .setting-save { display: none; }

/* --- Help ----------------------------------------------------------------- */

.help-lead {
  margin: -8px 0 16px;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

.help-toc { padding: 16px 18px; }
.help-toc-title { font-size: 17px; font-weight: 900; }
.help-toc ol { display: grid; gap: 2px; margin: 8px 0 0; padding-left: 22px; }

.help-toc a {
  display: inline-block;
  min-height: 34px;
  padding: 6px 0;
  color: var(--accent-blue-ink);
  font-size: 15.5px;
  font-weight: 800;
  text-decoration: none;
}

.help section { margin-top: 28px; scroll-margin-top: 16px; }
.help h2 { margin-bottom: 10px; font-size: 21px; font-weight: 900; }
.help h3 { margin: 16px 0 6px; font-size: 17px; font-weight: 800; }
.help p, .help li, .help dd { color: var(--text-secondary); font-size: 15.5px; font-weight: 600; line-height: 1.55; }
.help p + p { margin-top: 10px; }
.help strong { color: var(--text-primary); }
.help ol, .help ul { display: grid; gap: 6px; padding-left: 22px; }
.help dt { margin-top: 12px; color: var(--text-primary); font-size: 16px; font-weight: 800; }
.help dd { margin: 3px 0 0; }

.help-code {
  margin: 10px 0;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: var(--radius-tile);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
}


/* --- Paused session ------------------------------------------------------- */

.paused-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 20px;
  text-align: center;
}

.paused-label { font-size: 19px; font-weight: 900; }

.paused-meta {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
}

.paused-help { color: var(--text-secondary); font-size: 15px; }

.paused-panel form,
.paused-panel .btn { width: 100%; }

.paused-panel form { margin-top: 6px; }

.setup-paused {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.setup-paused-text { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; }

.setup-paused-text strong { display: block; font-size: 15px; font-weight: 900; }
