/* ---------- Design tokens ---------- */
:root {
  --bg:        #0b0d12;
  --bg-soft:   #11141c;
  --surface:   rgba(255,255,255,.035);
  --surface-2: rgba(255,255,255,.06);
  --border:    rgba(255,255,255,.09);
  --border-2:  rgba(255,255,255,.16);
  --text:      #e9ecf5;
  --text-dim:  #9aa3b8;
  --text-mute: #6b7488;
  --accent:    #8b5cf6;
  --accent-2:  #22d3ee;
  --shadow:    0 18px 50px -20px rgba(0,0,0,.75);
  --radius:    16px;

  --todo:   #7c8698;
  --doing:  #f59e0b;
  --done:   #10b981;
  --review: #38bdf8;

  --t-c: #3b82f6; --t-ocaml: #f97316; --t-archi: #06b6d4; --t-sql: #22c55e;
  --t-ia: #a855f7; --t-theorie: #ec4899; --t-python: #eab308; --t-default: #64748b;
}

[data-theme="light"] {
  --bg:        #f6f7fb;
  --bg-soft:   #ffffff;
  --surface:   #ffffff;
  --surface-2: #f1f3f9;
  --border:    rgba(15,23,42,.09);
  --border-2:  rgba(15,23,42,.18);
  --text:      #0f172a;
  --text-dim:  #566078;
  --text-mute: #8b94a9;
  --shadow:    0 14px 40px -22px rgba(15,23,42,.45);
  --todo:      #94a3b8;
}

* { box-sizing: border-box; }

/* doit primer sur les display: flex/grid des composants masqués par [hidden] */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

.aurora {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60rem 30rem at 12% -10%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(48rem 28rem at 92% 0%, color-mix(in oklab, var(--accent-2) 16%, transparent), transparent 70%);
  opacity: .8;
  transform: translateZ(0);
}
[data-theme="light"] .aurora { opacity: .45; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
      stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 20px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transform: translateZ(0);      /* couche dediee : evite de recomposer au scroll */
  will-change: backdrop-filter;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 20px -6px var(--accent);
}
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand p  { margin: 0; font-size: 12px; color: var(--text-mute); white-space: nowrap; }

.tabs { display: flex; gap: 4px; padding: 4px; margin-right: auto;
        background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.tabs button {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 15px; border: 0; border-radius: 999px; background: transparent;
  color: var(--text-dim); font-size: 13.5px; font-weight: 550; white-space: nowrap;
  transition: background .18s, color .18s;
}
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button.on { color: var(--text); background: var(--surface-2);
                  box-shadow: inset 0 0 0 1px var(--border-2); }
.tabs .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tabs .pct { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--text-mute); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-mute); }
.search input {
  width: 240px; padding: 8px 40px 8px 34px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; outline: none; transition: border-color .18s, width .2s;
}
.search input:focus { border-color: var(--border-2); width: 290px; }
.search kbd {
  position: absolute; right: 9px; padding: 1px 6px; font-size: 11px;
  color: var(--text-mute); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px;
}

.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-dim);
  transition: color .18s, background-color .18s, border-color .18s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-2); }
#theme-toggle .ico-sun { display: none; }
[data-theme="light"] #theme-toggle .ico-sun { display: block; }
[data-theme="light"] #theme-toggle .ico-moon { display: none; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  min-width: 220px; padding: 6px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.menu button, .menu a {
  display: block; width: 100%; padding: 9px 12px; text-align: left;
  background: none; border: 0; border-radius: 8px;
  color: var(--text-dim); font-size: 13.5px; text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--surface-2); color: var(--text); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }

/* ---------- Page ---------- */
.page { max-width: 1480px; margin: 0 auto; padding: 26px clamp(16px, 3vw, 34px) 80px; }

/* ---------- Dashboard ---------- */
.dash {
  display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center;
  padding: 20px 24px; margin-bottom: 22px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
@media (max-width: 780px) { .dash { grid-template-columns: 1fr; gap: 18px; } }

.ring { position: relative; width: 108px; height: 108px; }
.ring svg { width: 108px; height: 108px; transform: rotate(-90deg); stroke-width: 9; }
.ring .track { stroke: var(--surface-2); }
.ring .bar   { stroke: url(#ringgrad); stroke-linecap: round;
               transition: stroke-dashoffset .7s cubic-bezier(.22,1,.36,1); }
.ring .label {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.ring .label b { display: block; font-size: 25px; font-weight: 650; letter-spacing: -.02em;
                 font-variant-numeric: tabular-nums; }
.ring .label span { font-size: 10.5px; color: var(--text-mute); text-transform: uppercase;
                    letter-spacing: .09em; }

.dash-main { min-width: 0; }
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.stat {
  display: flex; align-items: center; gap: 9px; padding: 9px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
}
.stat i { width: 9px; height: 9px; border-radius: 50%; }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--text-dim); }

.heat { display: flex; flex-wrap: wrap; gap: 5px; }
.heat .cell {
  position: relative; flex: 1 1 18px; min-width: 18px; max-width: 46px; height: 30px;
  border-radius: 7px; border: 1px solid transparent; background: var(--surface-2);
  font-size: 10.5px; color: var(--text-mute); display: grid; place-items: center;
  transition: transform .15s;
}
.heat .cell:hover { transform: translateY(-2px); }
.heat .cell.now { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
           justify-content: space-between; margin-bottom: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filters-right { display: flex; gap: 8px; align-items: center; }

.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-dim); font-size: 13px; font-weight: 500;
  transition: color .16s, background-color .16s, border-color .16s;
}
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--todo)); }
.chip b { font-variant-numeric: tabular-nums; color: var(--text-mute); font-weight: 550; }
.chip.on {
  color: var(--text); border-color: color-mix(in oklab, var(--c, var(--accent)) 55%, transparent);
  background: color-mix(in oklab, var(--c, var(--accent)) 16%, var(--surface));
}

select {
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; outline: none;
}

.seg { display: flex; gap: 2px; padding: 3px; background: var(--surface);
       border: 1px solid var(--border); border-radius: 10px; }
.seg button { display: grid; place-items: center; width: 30px; height: 28px;
              border: 0; border-radius: 7px; background: transparent; color: var(--text-mute); }
.seg button.on { background: var(--surface-2); color: var(--text); }

/* ---------- Board ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.group-title {
  display: flex; align-items: center; gap: 10px; margin: 26px 0 12px;
  font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-mute);
}
.group-title:first-child { margin-top: 0; }
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.card {
  position: relative; display: flex; flex-direction: column; gap: 11px;
  padding: 16px 17px; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  contain: layout paint style;   /* isole le calcul de chaque carte */
  transition: transform .16s cubic-bezier(.22,1,.36,1), border-color .16s;
}
.card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--c, var(--t-default));
}
.card:hover { transform: translateY(-3px); border-color: var(--border-2); }
.card.is-done { opacity: .72; }
.card.is-done:hover { opacity: 1; }
.card.now { border-color: color-mix(in oklab, var(--accent) 50%, var(--border)); }

.card-top { display: flex; align-items: center; gap: 10px; }
.wk {
  display: inline-flex; align-items: baseline; gap: 4px; padding: 3px 9px;
  background: var(--surface-2); border-radius: 8px;
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  letter-spacing: .04em; text-transform: uppercase;
}
.wk b { font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.dates { font-size: 11.5px; color: var(--text-mute); }
.now-tag { padding: 2px 8px; border-radius: 999px; font-size: 10.5px;
           font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
           color: var(--accent); background: color-mix(in oklab, var(--accent) 16%, transparent); }

.status-btn {
  display: inline-flex; align-items: center; gap: 7px; margin-left: auto;
  padding: 4px 11px 4px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  border: 1px solid color-mix(in oklab, var(--s) 45%, transparent);
  background: color-mix(in oklab, var(--s) 16%, transparent);
  color: color-mix(in oklab, var(--s) 82%, var(--text));
  transition: background-color .16s;
}
.status-btn:hover { background: color-mix(in oklab, var(--s) 28%, transparent); }
.status-btn i { width: 8px; height: 8px; border-radius: 50%; background: var(--s); }

.card h3 { margin: 0; font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; line-height: 1.35; }
.card p.desc {
  margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 11.5px; font-weight: 550;
  color: color-mix(in oklab, var(--c) 85%, var(--text));
  background: color-mix(in oklab, var(--c) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--c) 32%, transparent);
}
.tag.sub { opacity: .72; }
.card-foot { display: flex; gap: 12px; margin-top: auto; padding-top: 3px;
             font-size: 11.5px; color: var(--text-mute); }
.card-foot span { display: inline-flex; align-items: center; gap: 5px; }
.card-foot svg { width: 13px; height: 13px; }
.card-foot .has { color: var(--doing); }

/* ---------- List density ---------- */
.list .grid { grid-template-columns: 1fr; gap: 8px; }
.list .card { flex-direction: row; align-items: center; gap: 14px; padding: 11px 15px; }
.list .card p.desc { -webkit-line-clamp: 1; flex: 1; margin: 0; }
.list .card h3 { font-size: 14px; flex: 0 0 clamp(180px, 22vw, 320px); }
.list .card-top { flex: none; }
.list .card .tags { flex: none; }
.list .card-foot { padding-top: 0; }
@media (max-width: 900px) { .list .card { flex-wrap: wrap; } .list .card h3 { flex: 1 1 100%; } }

/* ---------- Compare view ---------- */
.compare { display: flex; flex-direction: column; gap: 10px; }
.compare-head {
  position: sticky; top: 68px; z-index: 20;
  display: grid; grid-template-columns: 74px 1fr 1fr; gap: 10px;
  padding: 10px 4px; background: var(--bg);
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-mute);
}
.compare-row { display: grid; grid-template-columns: 74px 1fr 1fr; gap: 10px; align-items: stretch; }
.compare-row .wk-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 12px;
}
.compare-row .wk-cell b { font-size: 17px; font-variant-numeric: tabular-nums; }
.compare-row .wk-cell span { font-size: 10px; color: var(--text-mute); }
.compare-row .wk-cell.now { border-color: var(--accent); color: var(--accent); }
.compare-row .hole { border: 1px dashed var(--border); border-radius: var(--radius); }
@media (max-width: 860px) {
  .compare-head { display: none; }
  .compare-row { grid-template-columns: 1fr; }
}

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(4,6,12,.55);
         animation: fade .18s ease; }
@keyframes fade { from { opacity: 0 } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 80;
  width: min(560px, 100vw); display: flex; flex-direction: column;
  background: var(--bg-soft); border-left: 1px solid var(--border);
  box-shadow: -30px 0 70px -30px rgba(0,0,0,.7);
  animation: slide .24s cubic-bezier(.22,1,.36,1);
  will-change: transform;
}
@keyframes slide { from { transform: translateX(100%) } }

.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.drawer-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .1em;
                  text-transform: uppercase; color: var(--accent); }
.drawer-head h2 { margin: 2px 0 0; font-size: 18px; font-weight: 650; letter-spacing: -.015em; }
.drawer-head-actions { display: flex; align-items: center; gap: 10px; }
.saved { font-size: 11.5px; color: var(--done); opacity: 0; transition: opacity .3s; }
.saved.show { opacity: 1; }

.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain;
               padding: 18px 20px 26px;
               display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 11.5px; font-weight: 600; letter-spacing: .07em;
                text-transform: uppercase; color: var(--text-mute); }
.field input, .field textarea {
  width: 100%; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; outline: none;
  resize: vertical; transition: border-color .16s, background .16s;
}
.field input:focus, .field textarea:focus {
  border-color: color-mix(in oklab, var(--accent) 55%, var(--border));
  background: var(--surface-2);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.status-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.status-picker button {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  border-radius: 10px; font-size: 13px; font-weight: 550;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  transition: color .16s, background-color .16s, border-color .16s;
}
.status-picker button i { width: 9px; height: 9px; border-radius: 50%; background: var(--s); }
.status-picker button.on {
  color: var(--text); background: color-mix(in oklab, var(--s) 18%, var(--surface));
  border-color: color-mix(in oklab, var(--s) 55%, transparent);
}

.drawer-foot { display: flex; align-items: center; justify-content: space-between;
               gap: 12px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.muted { font-size: 11.5px; color: var(--text-mute); }

.btn { padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 550;
       background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
       transition: color .16s, background-color .16s, border-color .16s; }
.btn:hover { border-color: var(--border-2); color: var(--text); }
.btn.primary { background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent-2) 60%, var(--accent)));
               border-color: transparent; color: #0b0d12; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger:hover { color: #f87171; border-color: color-mix(in oklab, #f87171 45%, transparent);
                    background: color-mix(in oklab, #f87171 12%, transparent); }

/* ---------- Modal / toast ---------- */
.modal {
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft); color: var(--text); box-shadow: var(--shadow);
  width: min(440px, calc(100vw - 32px));
}
.modal::backdrop { background: rgba(4,6,12,.55); backdrop-filter: blur(3px); }
.modal form { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal h3 { margin: 0; font-size: 16.5px; font-weight: 650; }
.modal .modal-actions { display: flex; flex-direction: row-reverse;
                        justify-content: flex-start; gap: 8px; }
#modal-body { display: flex; flex-direction: column; gap: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 100;
  padding: 11px 18px; background: var(--bg-soft); border: 1px solid var(--border-2);
  border-radius: 12px; box-shadow: var(--shadow); font-size: 13.5px;
  animation: pop .25s cubic-bezier(.22,1,.36,1);
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 12px) } }

.empty { padding: 60px 0; text-align: center; color: var(--text-mute); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px;
                            border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1080px) {
  .topbar { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .search input { width: 180px; }
  .search input:focus { width: 210px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
