/* ───────── Variables / thèmes ───────── */
:root {
  --bg: #0a0c16;
  --orb1: #5b4bff; --orb2: #ff4fa3; --orb3: #19c3d6;
  --glass: rgba(255, 255, 255, .06);
  --glass-strong: rgba(24, 27, 46, .82);
  --border: rgba(255, 255, 255, .11);
  --text: #eceefb;
  --muted: #9aa0c0;
  --primary: #7c6cff;
  --primary-2: #b06cff;
  --danger: #ff5d73;
  --ok: #3ddc97;
  --warn: #ffb547;
  --field: rgba(255, 255, 255, .06);
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --radius: 16px;
  --blur: blur(18px) saturate(140%);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef0fb;
  --orb1: #8f84ff; --orb2: #ff9ac8; --orb3: #7fe3ee;
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .92);
  --border: rgba(30, 35, 80, .12);
  --text: #1b1e3a;
  --muted: #666b8c;
  --field: rgba(255, 255, 255, .8);
  --shadow: 0 10px 30px rgba(60, 70, 130, .15);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #eef0fb;
    --orb1: #8f84ff; --orb2: #ff9ac8; --orb3: #7fe3ee;
    --glass: rgba(255, 255, 255, .62);
    --glass-strong: rgba(255, 255, 255, .92);
    --border: rgba(30, 35, 80, .12);
    --text: #1b1e3a;
    --muted: #666b8c;
    --field: rgba(255, 255, 255, .8);
    --shadow: 0 10px 30px rgba(60, 70, 130, .15);
    color-scheme: light;
  }
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
  background: var(--bg); color: var(--text);
}
body.no-scroll { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.7rem; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.danger-text { color: var(--danger); }
.pre { white-space: pre-wrap; }
.selectable { user-select: text; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Fond animé */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-orbs i {
  position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%;
  filter: blur(90px); opacity: .38; animation: float 26s ease-in-out infinite alternate;
}
.bg-orbs i:nth-child(1) { background: var(--orb1); top: -18vmax; left: -12vmax; }
.bg-orbs i:nth-child(2) { background: var(--orb2); bottom: -22vmax; right: -14vmax; animation-delay: -9s; }
.bg-orbs i:nth-child(3) { background: var(--orb3); top: 35%; left: 40%; width: 30vmax; height: 30vmax; opacity: .22; animation-delay: -16s; }
@keyframes float { to { transform: translate(6vmax, 4vmax) scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .bg-orbs i { animation: none; } * { transition: none !important; } }

.glass {
  background: var(--glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ───────── Barre du haut ───────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; border-width: 0 0 1px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-size: .95rem;
  box-shadow: 0 4px 14px rgba(124, 108, 255, .5);
}
.searchbox { position: relative; flex: 1; max-width: 420px; margin: 0 auto; }
.searchbox input[type=search] {
  width: 100%; padding: 8px 14px 8px 38px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--field); outline: none;
}
.searchbox input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 108, 255, .22); }
.search-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 1.1rem; pointer-events: none; }
.topnav { display: flex; gap: 4px; margin-left: auto; }
.nav-link {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 10px;
  background: none; border: 0; color: var(--muted); cursor: pointer; transition: .15s;
}
.nav-link:hover { background: var(--glass); color: var(--text); text-decoration: none; }
.nav-link.active { background: rgba(124, 108, 255, .18); color: var(--text); }
.nav-link .ico { font-size: 1.05rem; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* ───────── Boutons / champs ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 11px; border: 1px solid transparent;
  cursor: pointer; font-weight: 600; transition: transform .1s, filter .15s, background .15s;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 18px rgba(124, 108, 255, .35); }
.btn.ghost { background: var(--glass); border-color: var(--border); color: var(--text); }
.btn.danger { background: rgba(255, 93, 115, .14); border-color: rgba(255, 93, 115, .4); color: var(--danger); }
.btn.block { display: flex; width: 100%; margin-top: 8px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: none; border: 0; cursor: pointer; color: var(--muted); transition: .15s;
}
.icon-btn:hover { background: var(--glass); color: var(--text); }
.icon-btn.danger-text:hover { color: var(--danger); }

input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--field); outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 108, 255, .22); }
select option { background: #1c1f35; color: #eceefb; }
:root[data-theme="light"] select option { background: #fff; color: #1b1e3a; }
textarea { resize: vertical; }
label { display: grid; gap: 5px; font-size: .85rem; font-weight: 600; color: var(--muted); }
label input, label select, label textarea { font-weight: 400; color: var(--text); }
.stack { display: grid; gap: 14px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--field); border: 1px solid var(--border); }
.seg button { padding: 6px 14px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--primary); color: #fff; }
.small-seg button { padding: 4px 10px; font-size: .82rem; }
#theme-seg { display: flex; } #theme-seg button { flex: 1; }

/* ───────── Pages génériques ───────── */
.page { max-width: 1100px; margin: 0 auto; }
.page.narrow { max-width: 720px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 20px; }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); }
.panel { border-radius: var(--radius); padding: 18px; }
.panel h2 { margin-bottom: 14px; }
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: start; }
.rows { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; }
.rows.compact .row { background: var(--field); border: 1px solid var(--border); }
.row-main { flex: 1; min-width: 0; }
.row-title { overflow-wrap: anywhere; }
.row-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent, var(--muted)); flex: none; }
.composer { display: grid; gap: 8px; justify-items: end; }
.empty { text-align: center; padding: 44px 20px; border-radius: var(--radius); color: var(--muted); }
.empty-ico { font-size: 2.2rem; margin-bottom: 6px; }
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.list-card {
  display: grid; gap: 2px; padding: 14px; border-radius: 13px; color: var(--text);
  background: var(--field); border: 1px solid var(--border); transition: .15s;
}
.list-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--primary); }
.list-name { font-weight: 700; overflow-wrap: anywhere; }

.section-title { margin: 18px 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* Auth */
.auth { max-width: 400px; margin: 9vh auto 0; padding: 32px; border-radius: 22px; display: grid; gap: 14px; }
.flashes { max-width: 400px; margin: 0 auto 14px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 11px; border: 1px solid var(--border); background: var(--glass); }
.flash.error { border-color: rgba(255, 93, 115, .5); color: var(--danger); }
.flash.success { border-color: rgba(61, 220, 151, .5); color: var(--ok); }

/* ───────── Tableau ───────── */
.board-wrap { max-width: 1400px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.stats { display: flex; gap: 14px; color: var(--muted); flex-wrap: wrap; }
.stat b { color: var(--text); }
.stat.bad, .stat.bad b { color: var(--danger); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip-btn {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--glass); color: var(--muted); cursor: pointer; font-size: .82rem; font-weight: 600;
}
.chip-btn.on { background: rgba(255, 93, 115, .16); border-color: rgba(255, 93, 115, .5); color: var(--danger); }
.tag-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; min-height: 0; }
.tag-bar:empty { display: none; }

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.column {
  border-radius: var(--radius); padding: 12px; display: grid; gap: 10px;
  background: var(--glass); border: 1px solid var(--border);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  --col: var(--primary);
}
.col-todo { --col: #7c9bff; }
.col-progress { --col: var(--warn); }
.col-done { --col: var(--ok); }
.col-head { display: flex; align-items: center; gap: 9px; padding: 2px 4px; }
.col-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--col); box-shadow: 0 0 12px var(--col); }
.count { margin-left: auto; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--field); color: var(--muted); }
.quick-add { background: transparent; border-style: dashed; }
.quick-add:focus { background: var(--field); border-style: solid; }
.cards { display: grid; gap: 10px; min-height: 90px; align-content: start; padding: 2px; border-radius: 12px; transition: background .15s; }
.cards.over { background: rgba(124, 108, 255, .12); outline: 2px dashed rgba(124, 108, 255, .5); outline-offset: -2px; }
.col-empty { display: grid; place-items: center; min-height: 80px; color: var(--muted); font-size: .85rem; border: 1px dashed var(--border); border-radius: 12px; }

.card {
  position: relative; padding: 12px 14px 12px 17px; border-radius: 13px; cursor: pointer;
  display: grid; gap: 8px; overflow: hidden; transition: transform .15s, border-color .15s, box-shadow .15s;
  background: var(--glass-strong); box-shadow: 0 3px 12px rgba(0, 0, 0, .18);
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, transparent); }
.card:hover { transform: translateY(-2px); border-color: rgba(124, 108, 255, .55); }
.card.dragging { opacity: .35; transform: scale(.98); }
.card[draggable=true] { -webkit-user-drag: element; }
.card-title { font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card.is-done .card-title { text-decoration: line-through; color: var(--muted); }
.card-meta, .card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--field); color: var(--muted); border: 1px solid var(--border); }
.badge.prio-1 { color: #5fb7ff; } .badge.prio-2 { color: var(--warn); } .badge.prio-3 { color: var(--danger); background: rgba(255, 93, 115, .12); }
.badge.due.soon { color: var(--warn); } .badge.due.overdue { color: #fff; background: var(--danger); border-color: var(--danger); }
.badge.ok { color: var(--ok); }
.tag { font-size: .74rem; padding: 1px 8px; border-radius: 999px; background: rgba(124, 108, 255, .16); color: #b3a9ff; }
:root[data-theme="light"] .tag { color: #5b4bff; }
.chip { border: 0; cursor: pointer; font-weight: 600; padding: 4px 11px; }
.chip.on { background: var(--primary); color: #fff; }
.skeleton { height: 280px; border-radius: var(--radius); animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .45; } }

/* ───────── Modales ───────── */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 6, 14, .55); backdrop-filter: blur(4px); overflow-y: auto;
  animation: fade .15s;
}
.modal-card { width: min(420px, 100%); padding: 22px; border-radius: 20px; background: var(--glass-strong); animation: pop .18s; }
.modal-card.wide { width: min(640px, 100%); display: grid; gap: 14px; margin: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.title-input { font-size: 1.25rem; font-weight: 700; padding: 10px 12px; }
.grid-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.with-clear { display: flex; gap: 4px; align-items: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 3px; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  background: var(--field); color: var(--muted); font-size: .8rem; display: grid; place-items: center;
  box-shadow: 0 0 0 1px var(--border);
}
.swatch.on { border-color: var(--text); transform: scale(1.12); }
.subtasks-head { display: flex; align-items: baseline; justify-content: space-between; }
.subtasks .section-title { margin: 0 0 6px; }
.progress { height: 6px; border-radius: 99px; background: var(--field); overflow: hidden; margin-bottom: 8px; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--ok)); transition: width .25s; }
.subs { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.sub { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 8px; }
.sub:hover { background: var(--field); }
.sub span { flex: 1; overflow-wrap: anywhere; }
.sub.done span { text-decoration: line-through; color: var(--muted); }
.sub input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* Toasts */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; }
.toast {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 12px;
  background: var(--glass-strong); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: var(--blur); animation: pop .2s; transition: opacity .35s;
}
.toast.error { border-color: var(--danger); } .toast.success { border-color: rgba(61, 220, 151, .6); }
.toast.out { opacity: 0; }
.toast button { background: none; border: 0; color: var(--primary); font-weight: 700; cursor: pointer; }

/* ───────── Responsive ───────── */
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand-name, .nav-link .lbl { display: none; }
  .searchbox { order: 3; flex-basis: 100%; max-width: none; }
  main { padding: 12px; }
  .grid-fields { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .row { flex-wrap: wrap; }
}

/* ───────── Glisser-déposer générique ───────── */
.grip { cursor: grab; color: var(--muted); user-select: none; padding: 0 2px; flex: none; }
.grip:active { cursor: grabbing; }
.drop-over { outline: 2px dashed rgba(124, 108, 255, .5); outline-offset: -2px; border-radius: 12px; }
.row.dragging { opacity: .35; }
.row[draggable=true] { cursor: default; }

/* ───────── Notes ───────── */
.page-board main, body.page-notes main { max-width: none; }
.notes-wrap { height: calc(100vh - 100px); display: flex; flex-direction: column; }
.page-head.tight { margin-bottom: 12px; }
.notes-board {
  flex: 1; min-height: 0; display: flex; align-items: flex-start; gap: 16px;
  overflow-x: auto; overflow-y: hidden; padding: 4px 4px 16px; scroll-snap-type: x proximity;
}
.nb-col {
  flex: none; width: 300px; max-height: 100%; display: flex; flex-direction: column;
  border-radius: var(--radius); padding: 12px; gap: 10px; scroll-snap-align: start;
}
.nb-col.dragging { opacity: .4; }
.nb-head { display: flex; align-items: center; gap: 6px; }
.nb-title { font-weight: 700; font-size: 1rem; background: transparent; border-color: transparent; padding: 6px 8px; }
.nb-title:hover { border-color: var(--border); }
.nb-items { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 50px; padding: 2px; margin: 0 -2px; flex: 0 1 auto; }
.nb-empty { text-align: center; color: var(--muted); font-size: .85rem; padding: 14px 0; }
.nb-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border-radius: 11px; cursor: grab;
  background: var(--glass-strong); border: 1px solid var(--border); transition: border-color .15s;
}
.nb-item:hover { border-color: rgba(124, 108, 255, .55); }
.nb-item.dragging { opacity: .35; }
.nb-item input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); flex: none; }
.nb-text { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; user-select: none; }
.nb-item.done .nb-text { text-decoration: line-through; color: var(--muted); }
.nb-edit { flex: 1; padding: 4px 6px; resize: none; overflow: hidden; }
.nb-del { opacity: 0; width: 24px; height: 24px; flex: none; }
.nb-item:hover .nb-del, .nb-item:focus-within .nb-del { opacity: 1; }
@media (hover: none) { .nb-del { opacity: 1; } }
.nb-new { flex: none; width: 300px; padding: 12px; border: 2px dashed var(--border); border-radius: var(--radius); display: grid; gap: 6px; }
.nb-newtitle { background: transparent; }
.nb-items::-webkit-scrollbar, .notes-board::-webkit-scrollbar { width: 8px; height: 10px; }
.nb-items::-webkit-scrollbar-thumb, .notes-board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9px; }
@media (max-width: 680px) { .nb-col, .nb-new { width: 82vw; } .notes-wrap { height: calc(100vh - 150px); } }
