:root {
  --bg: #0f1115;
  --surface: #16191f;
  --surface-2: #1c2028;
  --border: #262b34;
  --text: #e6e8ec;
  --muted: #8b93a1;
  --accent: #4f8cff;
  --ok: #38b26b;
  --warn: #e5a13a;
  --danger: #e5484d;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding:
    calc(16px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(32px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.tabs {
  display: flex; gap: 4px; margin: 16px 0 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px;
}
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  border-radius: 9px; padding: 9px 10px; font-weight: 600; font-size: 14px;
}
.tab.active { background: var(--surface-2); color: var(--text); }

.filter {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 12px; margin: 0 0 6px 2px;
}
.filter select {
  flex: 1; max-width: 240px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 10px; font-size: 14px;
}

.section { margin: 18px 0 10px; }
.section h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted); margin: 0 0 8px 2px; font-weight: 650;
}
.section.urgent h2 { color: var(--danger); }
.section-count {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: #232833; color: var(--muted); letter-spacing: 0;
}
.section-hint { color: var(--muted); font-size: 11px; margin: -4px 0 8px 2px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}

.task {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; border-top: 1px solid var(--border);
  min-height: 58px;
}
.task:first-child { border-top: 0; }

.check {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #3a4150; background: transparent; padding: 0;
  transition: border-color .18s ease, background .18s ease;
}
.check:active { background: rgba(56, 178, 107, .18); border-color: var(--ok); }
.check:disabled { opacity: .5; }

.body { flex: 1 1 auto; min-width: 0; }
.title { font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-top: 4px; font-size: 11.5px; color: var(--muted);
}
.chip {
  padding: 1px 7px; border-radius: 999px;
  background: rgba(79, 140, 255, .13); color: #9cbcff;
}
.due.late { color: var(--danger); font-weight: 600; }
.prio-select {
  border: 0; border-radius: 999px; padding: 1px 4px 1px 8px;
  font-size: 10.5px; font-weight: 700; background: #232833;
  color: var(--muted); cursor: pointer;
}
.prio-select.rank-p0 { background: rgba(229, 72, 77, .22); color: #ff9a9d; }
.prio-select.rank-p1 { background: rgba(229, 161, 58, .16); color: #f0b45a; }
.prio-select.rank-p2 { background: rgba(79, 140, 255, .13); color: #9cbcff; }
.prio-select.rank-p3 { background: #232833; color: var(--muted); }
.prio-select:disabled { opacity: .5; }

.postpone {
  flex: 0 0 auto; border: 1px solid var(--border);
  background: transparent; color: var(--muted);
  border-radius: 9px; padding: 7px 9px; font-size: 12px;
}
.postpone:active { background: var(--surface-2); }

.empty { color: var(--muted); text-align: center; padding: 40px 10px; font-size: 14px; }

.btn {
  background: var(--accent); color: #06101f; border: 0; border-radius: 11px;
  padding: 11px 15px; font-weight: 650; min-height: 42px;
}
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.full { width: 100%; }

.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .58); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px;
}
@media (min-width: 600px) { .overlay { align-items: center; } }
.sheet {
  width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px;
}
.sheet h2 { font-size: 17px; margin: 0 0 10px; }
.modal-task { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: 12px; color: var(--muted); }
.field input {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; font-size: 15px; color: var(--text);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 400px) { .row2 { grid-template-columns: 1fr; } }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick .btn { flex: 1; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.error { color: var(--danger); font-size: 12.5px; margin: 8px 0 0; }
.muted { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 60;
  background: #232833; color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 16px; font-size: 13px; max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.toast.error { color: #ffb4b6; border-color: rgba(229, 72, 77, .5); }

/* ---------- comptes ---------- */
.top-actions { display: flex; align-items: center; gap: 8px; }
.user-chip {
  padding: 4px 9px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--muted); font-size: 11.5px;
  font-weight: 650; white-space: nowrap;
}
.login-sheet select { width: 100%; }
.field select,
.field textarea {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; font-size: 15px; color: var(--text);
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.45; }

/* ---------- tableau ---------- */
.board-scroll { margin: 8px -16px 0; }
.board {
  display: flex; align-items: flex-start; gap: 10px;
  overflow-x: auto; overscroll-behavior-x: contain;
  padding: 2px 16px 12px;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.board::-webkit-scrollbar { display: none; }
.column {
  flex: 0 0 84vw; max-width: 320px; min-height: 54vh;
  scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 9px;
  transition: border-color .15s ease, background .15s ease;
}
@media (min-width: 700px) {
  .column { flex-basis: 270px; }
}
.column.drop-target { border-color: var(--accent); background: rgba(79, 140, 255, .07); }
.column-head {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 4px 9px;
}
.column-head h2 {
  margin: 0; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
}
.column-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.column-todo .column-dot { background: #9cbcff; }
.column-doing .column-dot { background: var(--warn); }
.column-waiting .column-dot { background: #b78bff; }
.column-done .column-dot { background: var(--ok); }
.column-count {
  margin-left: auto; font-size: 11px; padding: 2px 7px;
  border-radius: 999px; background: #232833; color: var(--muted);
}
.column-body { display: flex; flex-direction: column; gap: 8px; }
.column-empty { color: var(--muted); font-size: 12.5px; margin: 8px 4px; }

.task-card {
  touch-action: manipulation;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 11px;
  cursor: pointer; outline: none;
  transition: border-color .15s ease, opacity .15s ease, transform .15s ease;
}
.task-card:active { transform: scale(.995); }
.task-card:focus-visible { border-color: var(--accent); }
.task-card.dragging { opacity: .45; }
.task-card.blocked { opacity: .58; }
.task-card.blocked:active { opacity: .75; }
.task-card.done { opacity: .62; }
.task-card.done .card-title { text-decoration: line-through; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-id {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px;
  color: var(--muted);
}
.prio-badge {
  font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 999px;
  background: #232833; color: var(--muted);
}
.prio-badge.rank-p0 { background: rgba(229, 72, 77, .22); color: #ff9a9d; }
.prio-badge.rank-p1 { background: rgba(229, 161, 58, .16); color: #f0b45a; }
.prio-badge.rank-p2 { background: rgba(79, 140, 255, .13); color: #9cbcff; }
.prio-badge.rank-p3 { background: #232833; color: var(--muted); }
.card-title {
  margin: 4px 0 7px; font-size: 14.5px; line-height: 1.3;
  overflow-wrap: anywhere;
}
.card-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
  color: var(--muted); font-size: 11px;
}
.card-meta .chip { font-size: 10.5px; }
.chip.source-vault { background: rgba(183, 139, 255, .14); color: #cdb3ff; }
.assignee { font-weight: 600; }
.blocked-note {
  display: flex; gap: 5px; align-items: flex-start;
  margin-top: 8px; padding: 6px 7px; border-radius: 8px;
  background: rgba(229, 161, 58, .11); color: #f0b45a;
  font-size: 11px; line-height: 1.35;
}
.blocked-note.private { background: rgba(139, 147, 161, .12); color: var(--muted); }
.card-links {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
  padding-top: 7px; border-top: 1px solid var(--border);
}
.card-links a {
  color: #9cbcff; font-size: 11px; text-decoration: none;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-links a:active { text-decoration: underline; }

/* ---------- fiche tâche ---------- */
.sheet { max-height: min(88vh, 760px); overflow-y: auto; }
.sheet-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 4px;
}
.sheet-head h2 { margin: 2px 0 0; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.icon-btn {
  flex: none; width: 34px; height: 34px; border-radius: 10px; padding: 0;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--muted); font-size: 20px; line-height: 1;
}
.modal-meta { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.modal-hint {
  margin: 8px 0 10px; padding: 8px 10px; border-radius: 9px;
  background: rgba(229, 161, 58, .1); color: #f0b45a;
  font-size: 12px; line-height: 1.4;
}
.modal-hint.private { background: rgba(139, 147, 161, .12); color: var(--muted); }
.status-picker {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 14px;
}
.status-choice {
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--muted); border-radius: 9px; padding: 9px 10px;
  font-size: 12.5px; font-weight: 650;
}
.status-choice.active { border-color: var(--accent); color: var(--text); background: rgba(79, 140, 255, .12); }
.mini-section { margin: 16px 0; }
.mini-section h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); margin: 0 0 8px;
}
.resource-row {
  border: 1px solid var(--border); border-radius: 11px;
  padding: 8px 10px 10px; margin-bottom: 8px;
}
.resource-row .field { margin: 6px 0; }
.remove-resource { width: 100%; margin-top: 2px; }
.dep-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 180px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 11px; padding: 5px;
}
.dep-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 6px; border-radius: 8px; font-size: 12.5px;
  color: var(--text); cursor: pointer;
}
.dep-item:active { background: var(--surface-2); }
.dep-item input { margin-top: 2px; accent-color: var(--accent); }
.dep-item strong { color: var(--muted); font-weight: 650; }
.small { font-size: 12px; }
.task .blocked-note { margin-top: 6px; }
