:root {
  --paper: #e9edf3;
  --card: #ffffff;
  --ink: #1d2740;
  --muted: #5d6880;
  --line: #c9d1de;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --today: #fff4d6;
  --late: #c8243a;
  --p-urgente: #d7263d;
  --p-haute: #ee8a1d;
  --p-normale: #8b95a8;
  --p-basse: #3aa0c6;
  --shadow: 0 1px 0 rgba(29, 39, 64, .12);
  --head: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141924;
    --card: #1f2634;
    --ink: #e5e9f1;
    --muted: #98a2b6;
    --line: #333c4f;
    --accent: #6c8dff;
    --accent-ink: #0d1322;
    --today: #3a3420;
    --late: #ff6b7d;
    --shadow: 0 1px 0 rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--body);
}
h1, h2, h3, .brand { font-family: var(--head); font-weight: 700; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

/* --- barre du haut --- */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: var(--card);
}
.brand { font-size: 18px; letter-spacing: -.01em; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tabs button {
  border: 0; background: none; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  color: var(--muted); font-family: var(--head); font-weight: 500; font-size: 15px;
}
.tabs button[aria-selected="true"] { color: var(--ink); background: var(--paper); }

button.primary, button.ghost, button.danger {
  border-radius: 6px; padding: 6px 14px; cursor: pointer; border: 1px solid transparent;
}
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.ghost { background: none; border-color: var(--line); }
button.danger { background: none; border-color: var(--late); color: var(--late); }
select, input, textarea {
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}

main { padding: 20px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar h2 { font-size: 22px; min-width: 190px; text-align: center; text-transform: capitalize; }

/* --- Kanban --- */
.board {
  display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 14px;
  overflow-x: auto; padding-bottom: 8px;
}
.col { background: color-mix(in srgb, var(--line) 35%, transparent); border-radius: 10px; padding: 10px; min-height: 200px; }
.col h3 { font-size: 15px; display: flex; justify-content: space-between; padding: 2px 4px 10px; }
.col h3 span { color: var(--muted); font-weight: 500; }
.col.done { opacity: .85; }
.cards { list-style: none; margin: 0; padding: 0; min-height: 120px; display: flex; flex-direction: column; gap: 8px; }

.card {
  background: var(--card); border-radius: 4px 8px 8px 4px; padding: 9px 11px 9px 13px;
  border-left: 5px solid var(--p-normale); box-shadow: var(--shadow); cursor: grab;
}
.card[data-priority="urgente"] { border-left-color: var(--p-urgente); }
.card[data-priority="haute"] { border-left-color: var(--p-haute); }
.card[data-priority="basse"] { border-left-color: var(--p-basse); }
.card .title { display: block; }
.card .meta { display: flex; gap: 10px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.card .late { color: var(--late); font-weight: 700; }
.col.done .card .title { text-decoration: line-through; text-decoration-color: var(--muted); }
.sortable-ghost { opacity: .35; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 4px; }

/* --- Planning --- */
.planning { display: grid; grid-template-columns: 1fr 260px; gap: 18px; align-items: start; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.calendar .dow { background: var(--card); text-align: center; font-size: 13px; color: var(--muted); padding: 6px 0; font-family: var(--head); }
.day { background: var(--card); min-height: 112px; padding: 6px; display: flex; flex-direction: column; }
.day.out { background: color-mix(in srgb, var(--card) 55%, var(--paper)); }
.day.out .num { color: var(--muted); }
.day.past .num { color: var(--muted); }
.day.today { background: var(--today); }
.day .num { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.day.today .num::after { content: " · aujourd'hui"; font-weight: 400; }
.day .cards { gap: 4px; min-height: 40px; flex: 1; }
.chip {
  background: var(--paper); border-left: 4px solid var(--p-normale); border-radius: 3px;
  padding: 2px 6px; font-size: 12.5px; line-height: 1.3; cursor: grab; overflow-wrap: anywhere;
}
.chip[data-priority="urgente"] { border-left-color: var(--p-urgente); }
.chip[data-priority="haute"] { border-left-color: var(--p-haute); }
.chip[data-priority="basse"] { border-left-color: var(--p-basse); }
.chip .proj { color: var(--muted); display: block; font-size: 11.5px; }

.side { background: var(--card); border-radius: 10px; padding: 14px; border-top: 4px solid var(--late); }
.side h3 { font-size: 16px; color: var(--late); margin-bottom: 8px; }
.mini-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; min-height: 30px; }
.mini-list .chip .proj { display: inline; margin-left: 6px; }

/* --- Projets --- */
table.projects { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; }
.projects th, .projects td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.projects th { font-family: var(--head); font-weight: 500; color: var(--muted); font-size: 13px; }
.projects tr.followed-no td:first-child { color: var(--muted); }
.projects .desc { display: block; color: var(--muted); font-size: 13px; }

/* --- dialogues --- */
dialog { border: 0; border-radius: 12px; padding: 22px; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(15, 20, 35, .45); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
dialog label > * { color: var(--ink); font-size: 15px; }
dialog .row { display: flex; gap: 12px; }
dialog .row label { flex: 1; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.spacer { flex: 1; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 8px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }

/* --- connexion --- */
body.login { min-height: 100vh; display: grid; place-items: center; }
.login-box { background: var(--card); padding: 32px; border-radius: 12px; width: min(340px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 24px; margin-bottom: 6px; }
.login-box button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px; padding: 8px; font-weight: 700; cursor: pointer; }
.err { color: var(--late); margin: 0; min-height: 1.4em; }

@media (max-width: 800px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  main { padding: 16px; }
  .planning { grid-template-columns: 1fr; }
  .calendar { grid-template-columns: repeat(7, minmax(44px, 1fr)); overflow-x: auto; }
  .day { min-height: 80px; padding: 3px; }
  .day.today .num::after { content: ""; }
  .chip .proj { display: none; }
  .projects th:nth-child(4), .projects td:nth-child(4) { display: none; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
