/* =========================================================
   DSN POWER — Modern UI
   Compatible avec la structure CSS existante
   ========================================================= */

:root {
  /* ---------- Couleurs ---------- */
  --bg: #f5f7fb;
  --bg-img: none;

  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-hover: #f1f5f9;

  --text: #172033;
  --text-strong: #0f172a;
  --muted: #64748b;
  --muted-light: #94a3b8;

  --border: #e2e8f0;
  --border-light: #edf1f5;

  /* Identité DSN Power */
  --accent: #2563eb;
  --accent-light: #3b82f6;
  --accent-dark: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #eff6ff;

  --orange: #f97316;
  --orange-light: #fb923c;
  --orange-bg: #fff7ed;

  --rouge: #ef4444;
  --rouge-bg: #fef2f2;

  --vert: #10b981;
  --vert-bg: #ecfdf5;

  --info: #0ea5e9;
  --info-bg: #f0f9ff;

  /* ---------- Formes ---------- */
  --radius-xs: 7px;
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;

  /* ---------- Ombres ---------- */
  --shadow-xs:
    0 1px 2px rgba(15, 23, 42, 0.04);

  --shadow:
    0 1px 3px rgba(15, 23, 42, 0.05),
    0 4px 12px rgba(15, 23, 42, 0.035);

  --shadow-hover:
    0 8px 24px rgba(15, 23, 42, 0.08);

  --shadow-lg:
    0 20px 50px rgba(15, 23, 42, 0.14);

  /* ---------- Typographie ---------- */
  --font-sans:
    "Plus Jakarta Sans",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  --font-size: 15px;

  /* ---------- Transitions ---------- */
  --transition:
    160ms cubic-bezier(.4, 0, .2, 1);
}


/* =========================================================
   DARK MODE
   ========================================================= */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #111827;
    --surface-soft: #172033;
    --surface-hover: #1e293b;

    --text: #e5e7eb;
    --text-strong: #f8fafc;
    --muted: #94a3b8;
    --muted-light: #64748b;

    --border: #263244;
    --border-light: #1e293b;

    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --accent-dark: #2563eb;
    --accent-soft: #172554;

    --orange: #fb923c;
    --orange-light: #fdba74;
    --orange-bg: #431407;

    --rouge-bg: #450a0a;
    --vert-bg: #052e1b;
    --info-bg: #082f49;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-soft: #172033;
  --surface-hover: #1e293b;

  --text: #e5e7eb;
  --text-strong: #f8fafc;
  --muted: #94a3b8;
  --muted-light: #64748b;

  --border: #263244;
  --border-light: #1e293b;

  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-dark: #2563eb;
  --accent-soft: #172554;

  --orange: #fb923c;
  --orange-light: #fdba74;
  --orange-bg: #431407;

  --rouge-bg: #450a0a;
  --vert-bg: #052e1b;
  --info-bg: #082f49;
}


/* =========================================================
   BASE
   ========================================================= */

* {
  box-sizing: border-box;
}

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

body {
  background-color: var(--bg);
  background-image: var(--bg-img);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;

  color: var(--text);

  font-family: var(--font-sans);
  font-size: var(--font-size);
  line-height: 1.5;

  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  min-height: 100vh;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
}


/* =========================================================
   LAYOUT
   ========================================================= */

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


/* =========================================================
   SIDEBAR
   ========================================================= */

.sidebar {
  width: 238px;
  flex-shrink: 0;

  background:
    linear-gradient(
      180deg,
      #0f172a 0%,
      #111c31 100%
    );

  border-right: 1px solid rgba(255,255,255,.06);

  padding: 18px 12px;

  display: flex;
  flex-direction: column;
  gap: 5px;

  color: #cbd5e1;

  position: relative;
  z-index: 50;
}

.sidebar .brand {
  display: flex;
  align-items: center;

  font-weight: 800;
  font-size: 1.18rem;

  padding: 10px 12px 24px;

  color: #f8fafc;

  letter-spacing: -.02em;
}

.sidebar .brand span {
  color: #60a5fa;
}

.brand-logo {
  width: 30px;
  height: 30px;
  flex-shrink: 0;

  margin-right: 8px;

  vertical-align: middle;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.nav-logout {
  display: flex;
  align-items: center;
  gap: 11px;

  width: 100%;
  padding: 10px 12px;

  border-radius: 10px;
  border: 1px solid transparent;

  background: transparent;
  color: #94a3b8;

  font-weight: 600;
  font-size: .9rem;

  text-align: left;

  transition: background var(--transition), color var(--transition);
}

.nav-logout:hover {
  background: rgba(239,68,68,.12);
  color: #f87171;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;

  padding: 10px 12px;

  border-radius: 10px;
  border: 1px solid transparent;

  color: #94a3b8;

  text-decoration: none;

  font-weight: 600;
  font-size: .9rem;

  background: transparent;

  text-align: left;
  width: 100%;

  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    transform var(--transition);
}

.nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #f8fafc;
}

.nav-link:active {
  transform: scale(.985);
}

.nav-link.active {
  background:
    linear-gradient(
      135deg,
      #2563eb,
      #1d4ed8
    );

  color: #ffffff;

  border-color: rgba(255,255,255,.08);

  box-shadow:
    0 5px 16px rgba(37,99,235,.25);
}


/* =========================================================
   MAIN
   ========================================================= */

.main {
  flex: 1;
  min-width: 0;

  padding: 26px 32px 90px;
    max-width: 1300px;
  
    margin-left: auto;
  margin-right: auto;
}


/* =========================================================
   CYCLE TOGGLE
   ========================================================= */

.cycle-toggle {
  display: inline-flex;

  background: var(--surface);

  border: 1px solid var(--border);

  border-radius: 999px;

  padding: 3px;
  margin-bottom: 12px;

  gap: 2px;

  box-shadow: var(--shadow-xs);
}

.cycle-pill {
  border: none;
  background: transparent;

  color: var(--muted);

  font-weight: 700;
  font-size: .82rem;

  padding: 7px 18px;

  border-radius: 999px;

  transition:
    background var(--transition),
    color var(--transition);
}

.cycle-pill:hover {
  color: var(--text);
}

.cycle-pill.active {
  background: var(--accent);
  color: #fff;

  box-shadow:
    0 2px 7px rgba(37,99,235,.25);
}


/* =========================================================
   TOPBAR
   ========================================================= */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;

  background: var(--surface);

  border: 1px solid var(--border-light);

  border-radius: var(--radius-lg);

  padding: 15px 20px;

  box-shadow: var(--shadow);

  margin-bottom: 20px;

  flex-wrap: wrap;
  gap: 14px;
}


/* =========================================================
   PROGRESSION
   ========================================================= */

.exam-gauge {
  flex: 1;
  min-width: 220px;
}

.exam-gauge .row {
  display: flex;
  justify-content: space-between;

  font-size: .82rem;
  color: var(--muted);

  margin-bottom: 7px;
}

.progress-bar {
  height: 9px;

  border-radius: 999px;

  background: var(--border);

  overflow: hidden;
}

.progress-bar > div {
  height: 100%;

  background:
    linear-gradient(
      90deg,
      var(--accent),
      var(--accent-light)
    );

  border-radius: inherit;

  transition: width .45s ease;
}


/* =========================================================
   BADGES
   ========================================================= */

.streak-badge,
.joker-badge {
  display: flex;
  align-items: center;
  gap: 6px;

  padding: 8px 13px;

  border-radius: 999px;

  font-size: .82rem;
  font-weight: 700;

  white-space: nowrap;
}

.streak-badge {
  background: var(--orange-bg);
  color: var(--orange);
}

.joker-badge {
  background: var(--accent-soft);
  color: var(--accent);

  border: 1px solid rgba(37,99,235,.12);
}

.level-badge {
  font-size: .78rem;
  color: var(--muted);

  white-space: nowrap;
}

.score-global-badge {
  display: flex;
  align-items: center;
  gap: 6px;

  padding: 8px 13px;

  border-radius: 999px;

  font-size: .82rem;
  font-weight: 700;

  white-space: nowrap;

  background: var(--vert-bg);
  color: var(--vert);
}


/* =========================================================
   HERO
   ========================================================= */

.hero {
  background:
    linear-gradient(
      135deg,
      var(--surface) 0%,
      var(--surface-soft) 100%
    );

  border: 1px solid var(--border-light);

  border-radius: var(--radius-lg);

  padding: 22px 24px;

  margin-bottom: 20px;

  box-shadow: var(--shadow);

  display: flex;
  align-items: center;
  justify-content: space-between;

  flex-wrap: wrap;
  gap: 16px;
}

.hero h2 {
  margin: 0 0 5px;

  font-size: 1.3rem;
  font-weight: 800;

  letter-spacing: -.025em;

  color: var(--text-strong);
}

.hero p {
  margin: 0;

  color: var(--muted);

  font-size: .92rem;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
  border: 1px solid transparent;

  border-radius: 10px;

  padding: 10px 17px;

  font-weight: 700;
  font-size: .88rem;

  background:
    linear-gradient(
      135deg,
      var(--accent),
      var(--accent-dark)
    );

  color: var(--accent-ink);

  box-shadow:
    0 3px 8px rgba(37,99,235,.18);

  transition:
    transform var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

.btn:hover {
  box-shadow:
    0 6px 16px rgba(37,99,235,.24);

  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(.985);
}

.btn.secondary {
  background: var(--surface);

  color: var(--text);

  border-color: var(--border);

  box-shadow: none;
}

.btn.secondary:hover {
  background: var(--surface-hover);

  border-color: #cbd5e1;
}

.btn.ghost {
  background: transparent;

  color: var(--accent);

  padding: 6px 10px;

  box-shadow: none;
}

.btn.ghost:hover {
  background: var(--accent-soft);
  transform: none;
}

.btn.danger {
  background: var(--rouge);
  box-shadow: 0 3px 8px rgba(239,68,68,.18);
}

.btn.small {
  padding: 7px 12px;
  font-size: .8rem;
}


/* =========================================================
   GRID
   ========================================================= */

.grid-2 {
  display: grid;

  grid-template-columns: 1.1fr 1fr;

  gap: 20px;
}

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


/* =========================================================
   CARDS
   ========================================================= */

.card {
  background: var(--surface);

  border: 1px solid var(--border-light);

  border-radius: var(--radius-lg);

  padding: 20px;

  box-shadow: var(--shadow);



  transition:
    box-shadow var(--transition),
    border-color var(--transition);
}

.card h3 {
  margin: 0 0 14px;

  font-size: .98rem;

  font-weight: 800;

  display: flex;
  align-items: center;
  gap: 8px;

  color: var(--text-strong);
}

.card .empty {
  color: var(--muted);

  font-size: .88rem;

  padding: 10px 0;
}


/* =========================================================
   RISK CARDS
   ========================================================= */

.risk-card {
  border: 1px solid var(--border);

  border-radius: var(--radius);

  padding: 13px 15px;

  margin-bottom: 10px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  gap: 12px;

  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.risk-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.risk-card.rouge {
  background: var(--rouge-bg);
  border-color: rgba(239,68,68,.15);
}

.risk-card.orange {
  background: var(--orange-bg);
  border-color: rgba(249,115,22,.15);
}

.risk-card .title {
  font-weight: 750;
  font-size: .9rem;
}

.risk-card .sub {
  font-size: .78rem;

  color: var(--muted);

  margin-top: 2px;
}

.tag {
  display: inline-block;

  font-size: .7rem;
  font-weight: 700;

  padding: 3px 8px;

  border-radius: 999px;

  margin-top: 4px;
}

.tag.rouge {
  background: var(--rouge);
  color: #fff;
}

.tag.orange {
  background: var(--orange);
  color: #fff;
}

.tag.accent {
  background: var(--accent);
  color: #fff;
}

.tache-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;

  font-size: .72rem;
  font-weight: 600;

  padding: 3px 6px 3px 10px;

  border-radius: 999px;

  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
}

.tache-chip button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1;
  padding: 2px;
}

.tache-chip button:hover {
  color: var(--rouge);
}

.chapitre-taches-row select {
  font-size: .72rem;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: var(--surface);
  color: var(--muted);
}

.tache-perso-table {
  width: 100%;
  border-collapse: collapse;
}

.tache-perso-table th {
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tache-perso-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.tache-perso-table input[type="text"] {
  min-width: 160px;
}

.matiere-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 420px;
}

.matiere-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.matiere-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}


/* =========================================================
   MATIERES
   ========================================================= */

.matiere-row {
  margin-bottom: 15px;
}

.matiere-row .head {
  display: flex;
  justify-content: space-between;

  font-size: .86rem;
  font-weight: 650;

  margin-bottom: 6px;
}

.mini-bar {
  height: 8px;

  border-radius: 999px;

  overflow: hidden;

  display: flex;

  background: var(--border);
}

.mini-bar span {
  height: 100%;
}

.mini-bar .vert {
  background: var(--vert);
}

.mini-bar .orange {
  background: var(--orange);
}

.mini-bar .rouge {
  background: var(--rouge);
}

.mini-bar .gris {
  background: var(--border);
}


/* =========================================================
   TASKS
   ========================================================= */

.task-row {
  display: flex;
  align-items: center;

  gap: 10px;

  padding: 10px 0;

  border-bottom: 1px solid var(--border-light);
}

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

.task-row .check {
  width: 20px;
  height: 20px;

  border-radius: 6px;

  border: 2px solid var(--border);

  flex-shrink: 0;

  background: transparent;
}

.task-row .check.done {
  background: var(--vert);
  border-color: var(--vert);
}

.task-row .check:disabled {
  opacity: .35;
  cursor: not-allowed;
}


/* =========================================================
   BADGE PILLS
   ========================================================= */

.badge-pill {
  background: var(--surface-soft);

  border: 1px solid var(--border);

  border-radius: 999px;

  padding: 3px 10px;

  font-size: .7rem;
  font-weight: 700;
}

.badge-pill.locked {
  opacity: .4;

  filter: grayscale(1);

  cursor: help;
}

.badge-star {
  cursor: help;
  font-size: .85em;
}

.badge-bonus {
  cursor: help;
  font-style: italic;
  font-weight: 800;
  color: var(--rouge);
}

.tache-perso-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.tache-perso-row:last-of-type {
  border-bottom: none;
}

.tache-legend {
  display: flex;
  align-items: center;
  gap: 6px;

  font-size: .78rem;
  color: var(--muted);

  margin-top: 10px;
}


/* =========================================================
   TABLE
   ========================================================= */

.tache-table {
  width: 100%;

  border-collapse: separate;
  border-spacing: 0;

  font-size: .86rem;
}

.tache-table th {
  text-align: left;

  font-size: .7rem;

  text-transform: uppercase;

  letter-spacing: .045em;

  color: var(--muted);

  padding: 9px 10px;

  border-bottom: 1px solid var(--border);

  white-space: nowrap;
}

.tache-table td {
  padding: 9px 10px;

  border-bottom: 1px solid var(--border-light);

  vertical-align: middle;

  white-space: nowrap;
}

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

.tache-table tbody tr {
  transition: background var(--transition);
}

.tache-table tbody tr:hover {
  background: var(--surface-soft);
}

.tache-table td.tache-label {
  white-space: normal;
  min-width: 130px;
}

.tache-table input.tache-score,
.tache-table select.tache-bareme {
  padding: 6px 9px;

  border-radius: 8px;

  border: 1px solid var(--border);

  background: var(--surface-soft);

  color: var(--text);

  font-size: .82rem;

  outline: none;

  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.tache-table input.tache-score:focus,
.tache-table select.tache-bareme:focus {
  border-color: var(--accent);

  box-shadow:
    0 0 0 3px rgba(37,99,235,.10);
}

.tache-resultat-pct {
  font-weight: 800;
}


/* =========================================================
   MODE TOGGLE / RATING
   ========================================================= */

.tache-mode-toggle {
  display: inline-flex;

  border: 1px solid var(--border);

  border-radius: 8px;

  overflow: hidden;

  margin-right: 6px;

  vertical-align: middle;
}

.tache-mode-toggle button {
  border: none;

  background: var(--surface-soft);

  color: var(--muted);

  font-size: .7rem;
  font-weight: 700;

  padding: 6px 8px;
}

.tache-mode-toggle button.active {
  background: var(--accent);
  color: #fff;
}

.rate {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
}

.rate button {
  width: 28px;
  height: 28px;

  border-radius: 8px;

  border: 1px solid var(--border);

  background: var(--surface-soft);

  color: var(--text);

  font-weight: 700;
  font-size: .8rem;

  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}

.rate button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rate button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}


/* =========================================================
   KEY / VALUE GRID
   ========================================================= */

.kv-grid {
  display: grid;

  grid-template-columns: repeat(4, 1fr);

  gap: 10px;

  margin: 15px 0;
}

.kv-grid > div {
  background: var(--surface-soft);

  border: 1px solid var(--border-light);

  border-radius: var(--radius);

  padding: 11px;

  text-align: center;
}

.kv-grid > div b {
  display: block;

  font-size: 1.1rem;

  color: var(--text-strong);
}

.kv-grid > div span {
  font-size: .7rem;

  color: var(--muted);
}


/* =========================================================
   STATUS DOTS
   ========================================================= */

.dot {
  width: 9px;
  height: 9px;

  border-radius: 50%;

  display: inline-block;
}

.dot.vert {
  background: var(--vert);
}

.dot.orange {
  background: var(--orange);
}

.dot.rouge {
  background: var(--rouge);
}

.dot.gris {
  background: var(--muted);
}


/* =========================================================
   FLOATING ACTION BUTTON
   ========================================================= */

.chrono-badge {
  position: fixed;
  left: 18px;
  bottom: 26px;
  z-index: 55;

  display: flex;
  align-items: center;
  gap: 6px;

  background: var(--rouge);
  color: #fff;
  border: none;

  padding: 10px 16px;
  border-radius: 999px;

  font-weight: 700;
  font-size: .88rem;

  box-shadow: var(--shadow-hover);
}

.score-chapitre-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  margin: 8px 0 16px;

  font-size: .9rem;
  font-weight: 600;

  color: var(--text);
}

.fab {
  position: fixed;

  bottom: 26px;
  right: 26px;

  height: 56px;
  padding: 0 24px;

  border-radius: 28px;

  background:
    linear-gradient(
      135deg,
      var(--accent-light),
      var(--accent-dark)
    );

  color: #fff;

  font-size: 1rem;
  font-weight: 700;

  box-shadow:
    0 10px 26px rgba(37,99,235,.32);

  border: none;

  z-index: 40;

  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);

  background: var(--vert, #16a34a);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;

  padding: 12px 22px;
  border-radius: 999px;

  box-shadow: 0 10px 26px rgba(0,0,0,.22);

  z-index: 60;

  animation: toast-in .25s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.fab:hover {
  transform: translateY(-2px) scale(1.03);

  box-shadow:
    0 14px 32px rgba(37,99,235,.38);
}


/* =========================================================
   MODAL
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;

  background: rgba(15,23,42,.58);

  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 100;

  padding: 16px;
}

.modal {
  background: var(--surface);

  border: 1px solid var(--border);

  border-radius: var(--radius-xl);

  padding: 24px;

  width: 100%;
  max-width: 840px;

  max-height: 100vh;

  overflow-y: auto;

  box-shadow: var(--shadow-lg);

  animation: modal-in .18s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal.large {
  max-width: min(1160px, 96vw);
}

.modal h3 {
  margin-top: 0;

  display: flex;
  justify-content: space-between;
  align-items: center;

  color: var(--text-strong);
}

.modal .close-x {
  background: transparent;

  border: none;

  font-size: 1.2rem;

  color: var(--muted);

  border-radius: 8px;

  padding: 5px;

  transition:
    background var(--transition),
    color var(--transition);
}

.modal .close-x:hover {
  background: var(--surface-hover);
  color: var(--text);
}


/* =========================================================
   FORMULAIRES
   ========================================================= */

.field {
  margin-bottom: 15px;
}

.field label {
  display: block;

  font-size: .7rem;

  font-weight: 700;

  margin-bottom: 1px;

  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;

  padding: 10px 12px;

  border-radius: 10px;

  border: 1px solid var(--border);

  background: var(--surface-soft);

  color: var(--text);

  font-size: .9rem;

  outline: none;

  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #cbd5e1;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  background: var(--surface);

  border-color: var(--accent);

  box-shadow:
    0 0 0 3px rgba(37,99,235,.10);
}

.suggestion {
  display: flex;
  align-items: center;

  gap: 8px;

  padding: 10px 12px;

  border: 1px solid var(--border);

  border-radius: 10px;

  margin-bottom: 8px;

  cursor: pointer;

  transition:
    border-color var(--transition),
    background var(--transition),
    transform var(--transition);
}

.suggestion:hover,
.suggestion.selected {
  border-color: var(--accent);

  background: var(--accent-soft);
}

.bareme-toggle {
  display: flex;

  gap: 8px;

  margin-top: 8px;
}

.bareme-toggle button {
  flex: 1;

  padding: 8px;

  border-radius: 8px;

  border: 1px solid var(--border);

  background: var(--surface-soft);

  font-weight: 700;

  color: var(--text);

  transition:
    background var(--transition),
    border-color var(--transition);
}

.bareme-toggle button.active {
  background: var(--accent);

  color: #fff;

  border-color: var(--accent);
}


/* =========================================================
   ACCORDION
   ========================================================= */

.accordion-item {
  border: 1px solid var(--border);

  border-radius: var(--radius);

  margin-bottom: 10px;

  overflow: hidden;

  background: var(--surface);

  transition: box-shadow var(--transition);
}

.accordion-item:hover {
  box-shadow: var(--shadow-xs);
}

.accordion-head {
  display: flex;

  justify-content: space-between;
  align-items: center;

  padding: 13px 16px;

  cursor: pointer;

  background: var(--surface);

  font-weight: 700;
}

.accordion-body {
  padding: 4px 16px 14px;
}

.chapitre-row {
  display: flex;

  align-items: center;

  justify-content: space-between;

  padding: 9px 0;

  border-top: 1px dashed var(--border);

  gap: 10px;
}

.chapitre-row .name {
  font-size: .88rem;
}

.chapitre-row .meta {
  font-size: .74rem;
  color: var(--muted);
}


/* =========================================================
   ONBOARDING
   ========================================================= */

.onboarding {
  max-width: 560px;

  margin: 40px auto;
}

.btn-link {
  background: none;

  border: none;

  color: var(--accent);

  font-weight: 700;

  cursor: pointer;

  padding: 0;

  font-size: inherit;
}

.onb-progress {
  display: flex;

  gap: 6px;

  margin-bottom: 22px;
}

.onb-progress > div {
  height: 5px;

  flex: 1;

  border-radius: 999px;

  background: var(--border);
}

.onb-progress > div.done {
  background: var(--accent);
}

.onb-card {
  background: var(--surface);

  border: 1px solid var(--border-light);

  border-radius: var(--radius-lg);

  padding: 28px;

  box-shadow: var(--shadow);
}

.onb-card h2 {
  margin-top: 0;

  color: var(--text-strong);

  letter-spacing: -.02em;
}

.choice-cards {
  display: grid;

  grid-template-columns: 1fr 1fr;

  gap: 10px;

  margin: 16px 0;
}

.choice-card {
  border: 2px solid var(--border);

  border-radius: var(--radius);

  padding: 14px;

  text-align: center;

  font-weight: 700;

  background: var(--surface-soft);

  transition:
    border-color var(--transition),
    background var(--transition),
    transform var(--transition);
}

.choice-card:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
}

.choice-card.selected {
  border-color: var(--accent);

  color: var(--accent);

  background: var(--accent-soft);
}

.onb-actions {
  display: flex;

  justify-content: space-between;

  margin-top: 22px;
}

.matiere-input-row {
  display: flex;

  gap: 8px;

  margin-bottom: 8px;

  align-items: center;
}

.matiere-input-row input[type=text] {
  flex: 2;
}

.matiere-input-row select {
  flex: 1;
}

.matiere-input-row button {
  flex-shrink: 0;
}


/* =========================================================
   STATISTIQUES
   ========================================================= */

.stat-block {
  margin-bottom: 22px;
}

.pie {
  width: 140px;
  height: 140px;

  border-radius: 50%;

  margin: 0 auto;
}

.legend {
  display: flex;

  gap: 14px;

  justify-content: center;

  margin-top: 12px;

  font-size: .8rem;

  flex-wrap: wrap;
}

.legend .item {
  display: flex;

  align-items: center;

  gap: 6px;
}


/* =========================================================
   CHRONOMÈTRE
   ========================================================= */

.chrono-display {
  font-size: 2.6rem;

  font-weight: 800;

  text-align: center;

  font-variant-numeric: tabular-nums;

  margin: 10px 0;

  letter-spacing: -.04em;
}

.chrono-controls {
  display: flex;

  gap: 10px;

  justify-content: center;
}


/* =========================================================
   ÉTATS VIDES
   ========================================================= */

.empty-state {
  text-align: center;

  padding: 45px 20px;

  color: var(--muted);
}


/* =========================================================
   CALENDRIER
   ========================================================= */

.calnav {
  display: flex;

  align-items: center;

  gap: 10px;

  flex-wrap: wrap;

  margin-bottom: 15px;
}

.calnav-mid {
  font-size: .86rem;

  display: flex;

  align-items: center;

  gap: 8px;
}


/* =========================================================
   EMPLOI DU TEMPS
   ========================================================= */

.edt-grid {
  display: grid;

  grid-template-columns: repeat(5, 1fr);

  gap: 12px;

  margin-bottom: 4px;
}

.edt-day {
  padding: 12px;

  min-width: 0;
}

.edt-day.today {
  border-color: var(--accent);

  box-shadow:
    0 0 0 2px rgba(37,99,235,.07);
}

.ev-card {
  display: flex;

  align-items: flex-start;

  gap: 6px;

  background: var(--surface);

  border: 1px solid var(--border);

  border-left: 4px solid var(--border);

  border-radius: 10px;

  padding: 8px;

  margin-bottom: 7px;

  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.ev-card:hover {
  transform: translateY(-1px);

  box-shadow: var(--shadow-xs);
}

.ev-card.done {
  background: var(--vert-bg);
}

.ev-chk {
  display: flex;

  align-items: center;

  padding-top: 2px;

  cursor: pointer;
}

.ev-chk input {
  width: 15px;
  height: 15px;

  cursor: pointer;
}

.ev-main {
  flex: 1;

  display: block;

  text-align: left;

  background: none;

  border: none;

  padding: 0;
  margin: 0;

  cursor: pointer;

  font: inherit;

  color: inherit;

  min-width: 0;
}

.ev-time {
  font-size: .67rem;

  color: var(--muted);
}

.ev-title {
  font-size: .74rem;

  font-weight: 750;

  margin-top: 1px;

  overflow-wrap: break-word;
}

.ev-sub {
  font-size: .64rem;

  color: var(--muted);

  margin-top: 1px;

  overflow-wrap: break-word;
}


/* =========================================================
   TOP STRIP
   ========================================================= */

.top-strip {
  display: flex;

  gap: 10px;

  margin-bottom: 16px;

  flex-wrap: wrap;
}


/* =========================================================
   ERREURS
   ========================================================= */

.err-wall {
  display: flex;

  flex-wrap: wrap;

  gap: 16px;

  align-items: flex-start;
}

.err-card {
  border: 1px solid var(--border);

  border-top: 4px solid var(--border);

  border-radius: var(--radius);

  padding: 13px 15px;

  background: var(--surface);

  box-shadow: var(--shadow-xs);

  width: fit-content;

  min-width: 190px;

  max-width: 280px;

  transition:
    box-shadow var(--transition),
    transform var(--transition);
}

.err-card:hover {
  transform: translateY(-1px);

  box-shadow: var(--shadow);
}

.err-card .meta {
  font-size: .7rem;

  color: var(--muted);

  margin-bottom: 6px;
}

.err-card .err-text {
  font-size: .86rem;

  white-space: pre-wrap;

  overflow-wrap: break-word;
}

.err-card.err-card-edit {
  max-width: 320px;

  width: 320px;
}

.err-card.err-card-edit select,
.err-card.err-card-edit textarea {
  width: 100%;
}

.search-row {
  margin-bottom: 14px;
}

.search-row input {
  width: 100%;
  max-width: 420px;

  padding: 10px 14px;

  border-radius: 10px;
  border: 1px solid var(--border);

  background: var(--surface-soft);
  color: var(--text);

  font-size: .9rem;

  outline: none;

  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

.search-row input:hover {
  border-color: #cbd5e1;
}

.search-row input:focus {
  background: var(--surface);
  border-color: var(--accent);

  box-shadow:
    0 0 0 3px rgba(37,99,235,.10);
}


/* =========================================================
   TITRES
   ========================================================= */

.page-title {
  font-size: 1.35rem;

  font-weight: 800;

  letter-spacing: -.025em;

  color: var(--text-strong);

  margin: 0 0 18px;
}

.section-gap {
  margin-top: 22px;
}

.hint {
  display: block;

  font-size: .74rem;

  color: var(--muted);

  margin-top: 4px;
}


/* =========================================================
   APPARENCE
   ========================================================= */

.swatches {
  display: flex;

  flex-wrap: wrap;

  gap: 10px;
}

.swatch {
  display: flex;

  flex-direction: column;

  align-items: center;

  gap: 6px;

  width: 76px;

  font-size: .7rem;

  color: var(--muted);

  background: none;

  border: none;

  padding: 0;

  text-align: center;
}

.swatch i {
  display: block;

  width: 100%;
  height: 44px;

  border-radius: 10px;

  border: 2px solid var(--border);

  overflow: hidden;

  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.swatch.active i,
.swatch[aria-pressed="true"] i {
  border-color: var(--accent);

  box-shadow:
    0 0 0 2px var(--accent) inset;
}

.font-swatch {
  display: flex;

  flex-direction: column;

  align-items: flex-start;

  gap: 2px;

  padding: 10px 14px;

  border-radius: 10px;

  border: 2px solid var(--border);

  background: var(--surface);

  cursor: pointer;

  min-width: 120px;

  transition:
    border-color var(--transition),
    background var(--transition);
}

.font-swatch:hover {
  background: var(--surface-soft);
}

.font-swatch b {
  font-size: 1.1rem;
}

.font-swatch span {
  font-size: .72rem;

  color: var(--muted);

  font-family: var(--font-sans);
}

.font-swatch.active {
  border-color: var(--accent);
}

.seg {
  display: inline-flex;

  border: 1px solid var(--border);

  border-radius: 10px;

  overflow: hidden;
}

.seg button {
  background: var(--surface);

  border: none;

  padding: 8px 14px;

  font-size: .8rem;

  font-weight: 600;

  color: var(--text);

  border-right: 1px solid var(--border);

  transition:
    background var(--transition),
    color var(--transition);
}

.seg button:last-child {
  border-right: none;
}

.seg button:hover {
  background: var(--surface-hover);
}

.seg button.active {
  background: var(--accent);

  color: var(--accent-ink);
}

.bg-thumb {
  width: 56px;
  height: 56px;

  border-radius: 10px;

  background-size: cover;
  background-position: center;

  border: 1px solid var(--border);

  flex-shrink: 0;
}

.matiere-color-input {
  width: 20px;
  height: 20px;

  padding: 0;

  border: 1px solid var(--border);

  border-radius: 50%;

  cursor: pointer;

  overflow: hidden;
}

.matiere-dot {
  display: inline-block;

  width: 10px;
  height: 10px;

  border-radius: 50%;

  margin-right: 7px;

  vertical-align: middle;
}


/* =========================================================
   TABLETTE
   ========================================================= */

@media (max-width: 1024px) {

  .sidebar {
    width: 76px;

    padding: 16px 8px;

    align-items: center;
  }

  .sidebar .brand {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

  .nav-link {
    flex-direction: column;

    gap: 4px;

    font-size: .61rem;

    padding: 10px 4px;

    text-align: center;
  }

  .main {
    padding: 20px 18px 90px;

    max-width: 100%;
  }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 680px) {

  .shell {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;

    bottom: 0;
    left: 0;
    right: 0;

    width: 100%;
    height: auto;

    z-index: 60;

    flex-direction: row;

    justify-content: space-around;
    align-items: stretch;

    gap: 0;

    padding:
      5px
      2px
      calc(5px + env(safe-area-inset-bottom));

    border-right: none;

    border-top:
      1px solid rgba(148,163,184,.18);

    overflow-x: auto;

    background:
      rgba(15,23,42,.96);

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .nav-link {
    flex: 1;

    min-width: 56px;

    padding: 8px 2px;

    font-size: .59rem;

    border-radius: 9px;
  }

  .nav-link.active {
    background: rgba(59,130,246,.13);

    color: #60a5fa;

    box-shadow: none;
  }

  .main {
    padding:
      15px
      12px
      calc(88px + env(safe-area-inset-bottom));

    max-width: 100%;
  }

  .topbar {
    padding: 14px;

    border-radius: var(--radius);

    margin-bottom: 15px;
  }

  .hero {
    padding: 18px;

    border-radius: var(--radius);

    margin-bottom: 15px;
  }

  .hero h2 {
    font-size: 1.15rem;
  }

  .card {
    padding: 16px;

    border-radius: var(--radius);
  }

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

  .choice-cards {
    grid-template-columns: 1fr;
  }

  .edt-grid {
    grid-template-columns: 1fr;
  }

  /* Types de tâche : le tableau est converti en pile de cartes, une par tâche, pour ne jamais
     avoir à scroller horizontalement sur téléphone. */
  .tache-perso-table,
  .tache-perso-table tbody {
    display: block;
    width: 100%;
  }

  .tache-perso-table thead {
    display: none;
  }

  .tache-perso-table tr {
    display: block;

    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  .tache-perso-table tr:last-child {
    border-bottom: none;
  }

  .tache-perso-table td {
    display: block;
    width: 100%;

    padding: 6px 0;
    border-bottom: none;
  }

  .tache-perso-table td[data-label]::before {
    content: attr(data-label);
    display: block;

    font-size: .68rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .03em;

    margin-bottom: 4px;
  }

  .tache-perso-table td[data-label=""]::before {
    content: none;
  }

  .tache-perso-table input[type="text"] {
    width: 100%;
    min-width: 0;
  }

  .matiere-chip-row {
    max-width: 100%;
  }

  .fab {
    bottom:
      calc(
        68px +
        env(safe-area-inset-bottom)
      ) !important;

    right: 18px;

    height: 52px;
    padding: 0 18px;
    font-size: 0.9rem;
  }

  .chrono-badge {
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(68px + env(safe-area-inset-bottom));

    font-size: .82rem;
    padding: 8px 14px;
  }

  .modal {
    border-radius: 18px;

    padding: 20px;

    max-height: 90vh;
  }

  .page-title {
    font-size: 1.2rem;
  }
}


/* =========================================================
   ACCESSIBILITÉ / FOCUS
   ========================================================= */

:focus-visible {
  outline: 3px solid rgba(59,130,246,.28);

  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
}


/* =========================================================
   RÉDUCTION DES ANIMATIONS
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;

    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;

    transition-duration: .01ms !important;
  }
}