/* =================================================================
   Gest Todo 2.0 — feuille de style
   1. Police  2. Jetons  3. Base  4. Composants  5. Application
   6. Tableau  7. Fenêtres  8. Authentification  9. Responsive
   ================================================================= */

/* 1. Police (auto-hébergée, disponible hors ligne) ---------------- */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/manrope-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* 2. Jetons ------------------------------------------------------- */
:root {
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --sidebar-w: 264px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 180ms;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #EDF0F4;
  --surface: #FFFFFF;
  --surface-2: #F5F7FA;
  --surface-3: #E5E9EF;
  --line: rgba(22, 32, 51, .09);
  --line-2: rgba(22, 32, 51, .17);
  --ink: #162033;
  --ink-2: #4B5568;
  --ink-3: #6F7A8D;
  --brand: #0E8A5F;
  --brand-hover: #0B744F;
  --brand-soft: #E1F2EA;
  --on-brand: #FFFFFF;
  --danger: #C2372E;
  --danger-soft: #FBE9E7;
  --warn: #B26A00;
  --warn-soft: #FDF1DC;
  --focus: #2563EB;

  --st-todo: #C27A0E;
  --st-progress: #2563EB;
  --st-deploy: #7C3AED;
  --st-done: #0E8A5F;

  --sidebar-bg: #F7F9FB;
  --toast-bg: #162033;
  --toast-ink: #F3F6FA;
  --shadow-1: 0 1px 2px rgba(22, 32, 51, .06);
  --shadow-2: 0 10px 30px -12px rgba(22, 32, 51, .28), 0 2px 6px rgba(22, 32, 51, .06);
  --shadow-3: 0 24px 60px -20px rgba(16, 24, 40, .45);
  --backdrop: rgba(16, 22, 32, .42);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11151C;
  --surface: #181D26;
  --surface-2: #1E2430;
  --surface-3: #283040;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .14);
  --ink: #E8ECF3;
  --ink-2: #AAB3C2;
  --ink-3: #8A94A6;
  --brand: #2FB37F;
  --brand-hover: #45C391;
  --brand-soft: rgba(47, 179, 127, .15);
  --on-brand: #06261A;
  --danger: #F0685E;
  --danger-soft: rgba(240, 104, 94, .14);
  --warn: #EBA94A;
  --warn-soft: rgba(235, 169, 74, .14);
  --focus: #7AA5FF;

  --st-todo: #E3A13B;
  --st-progress: #6C9BF5;
  --st-deploy: #A887F3;
  --st-done: #2FB37F;

  --sidebar-bg: #141921;
  --toast-bg: #E8ECF3;
  --toast-ink: #11151C;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 12px 30px -10px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-3: 0 24px 60px -16px rgba(0, 0, 0, .75);
  --backdrop: rgba(4, 6, 10, .62);
}

/* 3. Base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.col-count, .cat-count, .tab-count, .legend-item b, .pipeline-summary, .badge { font-variant-numeric: tabular-nums; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.i {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

[data-theme="light"] .i-theme-light,
[data-theme="dark"] .i-theme-dark { display: none; }

/* 4. Composants --------------------------------------------------- */

/* Marque */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand); color: var(--on-brand);
}
.brand-mark .i { width: 22px; height: 22px; stroke-width: 2.6; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent;
  font-size: 14px; font-weight: 650; letter-spacing: -.005em;
  text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 80ms;
}
.btn:active { transform: translateY(1px); }
.btn .i { width: 18px; height: 18px; }
.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-hover); }
.btn--ghost { border-color: var(--line-2); color: var(--ink-2); background: var(--surface); }
.btn--ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(1.08); }
.btn--danger-ghost { color: var(--danger); padding: 0 12px; }
.btn--danger-ghost:hover { background: var(--danger-soft); }
.btn--sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn--lg { height: 48px; font-size: 15px; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; pointer-events: none; }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn--sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn--sm .i { width: 17px; height: 17px; }

/* Champs */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; margin: 0; padding: 0; border: 0; }
.field-label { font-size: 13px; font-weight: 650; color: var(--ink-2); padding: 0; }
.field-hint { font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.field-error { font-size: 13px; font-weight: 600; color: var(--danger); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface-2); color: var(--ink);
  font-size: 15px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover { border-color: color-mix(in srgb, var(--ink) 28%, transparent); }
.input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
.input--lg { height: 48px; font-size: 16px; font-weight: 600; }
.input--icon { padding-left: 44px; }
.has-error .input, .input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { height: auto; min-height: 104px; padding: 12px 14px; line-height: 1.55; resize: vertical; }
input[type="date"].input { min-width: 0; }

.input-wrap { position: relative; }
.input-icon { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; width: 19px; height: 19px; }
.input-wrap:focus-within .input-icon { color: var(--brand); }
.input-reveal {
  position: absolute; right: 6px; top: 50%; translate: 0 -50%;
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-3);
}
.input-reveal:hover { color: var(--ink); background: var(--surface-3); }
.input-reveal .i-hide, .input-reveal.is-on .i-show { display: none; }
.input-reveal.is-on .i-hide { display: block; }
.input-wrap:has(.input-reveal) .input { padding-right: 48px; }

.select-wrap { position: relative; }
.select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.select-icon { position: absolute; right: 12px; top: 50%; translate: 0 -50%; pointer-events: none; color: var(--ink-3); width: 18px; height: 18px; }

/* Puces d'action rapide */
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  height: 28px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink-2);
  font-size: 12.5px; font-weight: 600;
}
.chip-btn:hover { border-color: var(--brand); color: var(--brand); }
.chip-btn--muted { color: var(--ink-3); }

/* Sélecteur segmenté (colonne) */
.segmented {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 4px; border-radius: 12px; background: var(--surface-3);
}
.segment { position: relative; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segment span {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 6px; border-radius: 9px;
  font-size: 13px; font-weight: 650; color: var(--ink-2); text-align: center;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segment span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--seg); flex: none; }
.segment--todo { --seg: var(--st-todo); }
.segment--in_progress { --seg: var(--st-progress); }
.segment--deploy { --seg: var(--st-deploy); }
.segment--done { --seg: var(--st-done); }
.segment input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.segment input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Nuancier */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; width: 34px; height: 34px; border-radius: 50%; background: var(--sw); cursor: pointer; }
.swatch input[type="radio"] { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch:has(input[type="radio"]:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw); }
.swatch:has(input[type="radio"]:focus-visible) { outline: 2px solid var(--focus); outline-offset: 4px; }
.swatch--custom {
  --sw: conic-gradient(from 0deg, #E5484D, #F5A524, #46A758, #0091FF, #8E4EC6, #E5484D);
  background: var(--sw); overflow: hidden;
}
.swatch--custom input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }
.swatch--custom:has(input[type="radio"]:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink-3); }

/* Alertes */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
}
.alert .i { width: 19px; height: 19px; margin-top: 1px; }
.alert--error { background: var(--danger-soft); color: var(--danger); }
.alert--info { background: var(--brand-soft); color: var(--brand); }

/* Notifications */
.toasts {
  position: fixed; z-index: 90;
  left: 50%; bottom: calc(24px + var(--safe-bottom)); translate: -50% 0;
  display: grid; gap: 8px; justify-items: center;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: 12px;
  background: var(--toast-bg); color: var(--toast-ink);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: toast-in 260ms var(--ease) both;
}
.toast .i { width: 18px; height: 18px; color: var(--brand); }
.toast--error .i { color: var(--danger); }
.toast.is-leaving { animation: toast-out 200ms var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* 5. Application -------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh; min-height: 100dvh;
}

/* Barre latérale */
.sidebar {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(20px + var(--safe-top)) 14px calc(16px + var(--safe-bottom)) calc(14px + var(--safe-left));
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 22px; }
.sidebar-close { display: none; }

.sidebar-nav { flex: 1; }
.nav-heading { padding: 0 10px 8px; font-size: 13px; font-weight: 700; color: var(--ink-3); }

.cat-list { display: grid; gap: 2px; }
.cat-item { position: relative; display: flex; align-items: center; }
.cat-link {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 10px; padding-right: 40px;
  border: 0; border-radius: 9px; background: transparent;
  font-size: 14px; font-weight: 600; color: var(--ink-2); text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.cat-link:hover { background: var(--surface-3); color: var(--ink); }
.cat-link[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.cat-link .i { width: 18px; height: 18px; color: var(--ink-3); }
.cat-dot { width: 10px; height: 10px; margin: 0 4px; border-radius: 3px; background: var(--cat); flex: none; }
.cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
.cat-edit {
  position: absolute; right: 4px;
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.cat-item:hover .cat-count, .cat-item:focus-within .cat-count { opacity: 0; }
.cat-item:hover .cat-edit, .cat-edit:focus-visible { opacity: 1; }
.cat-link .cat-count { position: absolute; right: 14px; }

.nav-add, .nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 38px; padding: 0 10px; margin-top: 4px;
  border: 0; border-radius: 9px; background: transparent;
  font-size: 14px; font-weight: 600; color: var(--ink-3); text-align: left; text-decoration: none;
}
.nav-add:hover, .nav-link:hover { background: var(--surface-3); color: var(--ink); }
.nav-add .i, .nav-link .i { width: 18px; height: 18px; }

.sidebar-foot { display: grid; gap: 2px; padding-top: 16px; border-top: 1px solid var(--line); }
.user { display: flex; align-items: center; gap: 10px; padding: 12px 4px 0 6px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  font-weight: 800; font-size: 15px;
}
.user-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user form { margin: 0; }

.scrim { display: none; }

/* Zone principale */
.main {
  min-width: 0;
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  padding: calc(22px + var(--safe-top)) calc(28px + var(--safe-right)) 0 28px;
}

.topbar { display: flex; align-items: center; gap: 16px; }
.menu-btn { display: none; }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 24px; line-height: 1.2; font-weight: 800; letter-spacing: -.025em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title p { font-size: 14px; color: var(--ink-3); font-weight: 600; }

.search { position: relative; display: block; width: min(320px, 32vw); }
.search-icon { position: absolute; left: 13px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.search-input {
  width: 100%; height: 40px; padding: 0 38px 0 40px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: 14px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search-input::placeholder { color: var(--ink-3); }
.search-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-kbd {
  position: absolute; right: 10px; top: 50%; translate: 0 -50%;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px;
  border: 1px solid var(--line-2); color: var(--ink-3);
  font: 600 11px/18px var(--font); text-align: center;
}
.search-input:focus + .search-kbd, .search-input:not(:placeholder-shown) + .search-kbd { display: none; }

/* Barre de pipeline : la pièce maîtresse */
.pipeline { padding: 22px 0 18px; }
.pipeline-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.pipeline-title { font-size: 14px; font-weight: 750; }
.pipeline-summary { font-size: 13.5px; font-weight: 600; color: var(--ink-3); text-align: right; }
.pipeline-summary strong { color: var(--ink); font-weight: 800; }
.pipeline-summary .is-late { color: var(--danger); }

.pipeline-bar {
  display: flex; gap: 3px; height: 14px;
  border-radius: var(--r-pill); overflow: hidden;
  background: var(--surface-3);
}
.pipeline-seg {
  min-width: 10px; height: 100%;
  background: var(--seg);
  transition: flex-grow 420ms var(--ease);
}
.pipeline-seg:first-child { border-radius: var(--r-pill) 0 0 var(--r-pill); }
.pipeline-seg:last-child { border-radius: 0 var(--r-pill) var(--r-pill) 0; }
.pipeline-seg:only-child { border-radius: var(--r-pill); }
.pipeline-seg--done {
  background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(255, 255, 255, .18) 5px 8px);
}

.pipeline-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.legend-item::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--seg); }
.legend-item b { color: var(--ink); font-weight: 800; }

/* Onglets (mobile) */
.tabs { display: none; }

/* 6. Tableau ------------------------------------------------------ */
.board {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 14px;
  position: relative;
  padding-bottom: calc(24px + var(--safe-bottom));
  overflow-x: auto;
  scrollbar-width: thin;
}

.col {
  --st: var(--st-todo);
  display: flex; flex-direction: column; min-height: 0;
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--st) 5%, var(--surface-2));
  border: 1px solid var(--line);
  border-top: 3px solid var(--st);
}
.col--in_progress { --st: var(--st-progress); }
.col--deploy { --st: var(--st-deploy); }
.col--done { --st: var(--st-done); }

.col-head { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 12px 12px 8px 16px; }
.col-title { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.col-count {
  min-width: 24px; height: 22px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--st) 14%, transparent);
  color: var(--st); font-size: 12.5px; font-weight: 800;
}
.col-add { margin-left: auto; }

.col-body {
  flex: 1; min-height: 120px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 10px 12px;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
}

.col-empty {
  display: grid; justify-items: center; gap: 6px;
  margin: 6px 2px; padding: 22px 14px;
  border: 1.5px dashed var(--line-2); border-radius: var(--r-md);
  color: var(--ink-3); font-size: 13.5px; font-weight: 600; text-align: center;
}
.col-empty .i { width: 22px; height: 22px; }
.col-empty button {
  border: 0; background: none; padding: 2px 4px;
  color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
}

/* Carte de tâche */
.card {
  --cat: transparent;
  position: relative;
  padding: 12px 12px 11px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1), inset 3px 0 0 var(--cat);
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.card:hover { border-color: var(--line-2); }
.card-open {
  all: unset;
  cursor: pointer;
}
.card-open::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card-open:focus-visible { outline: none; }
.card-open:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 2px; }
.card-title {
  font-size: 14.5px; font-weight: 700; line-height: 1.4; letter-spacing: -.005em;
  overflow-wrap: anywhere; padding-right: 30px;
}
.card-desc {
  margin-top: 3px;
  font-size: 13px; line-height: 1.5; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.card-meta:empty { display: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 8px; max-width: 100%;
  border-radius: 7px; background: var(--surface-2);
  font-size: 12px; font-weight: 700; color: var(--ink-2);
  white-space: nowrap;
}
.badge .i { width: 14px; height: 14px; }
.badge-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--cat); flex: none; }
.badge-text { overflow: hidden; text-overflow: ellipsis; }
.badge--late { background: var(--danger-soft); color: var(--danger); }
.badge--soon { background: var(--warn-soft); color: var(--warn); }

.card-advance {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface); color: var(--ink-3);
  z-index: 1;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card-advance .i { width: 15px; height: 15px; stroke-width: 2.4; }
.card:hover .card-advance, .card:focus-within .card-advance, .card-advance:focus-visible { opacity: 1; }
.card-advance:hover { background: var(--adv); border-color: var(--adv); color: #fff; }

.card--done .card-title { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: color-mix(in srgb, var(--ink-3) 60%, transparent); }
.card--done .card-desc { display: none; }
.card--done { box-shadow: inset 3px 0 0 var(--cat); background: color-mix(in srgb, var(--surface) 70%, transparent); }

mark.hl { background: color-mix(in srgb, var(--st-todo) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Glisser-déposer */
.card--ghost { opacity: .35; border-style: dashed; border-color: var(--st); box-shadow: none; }
.card--ghost > * { visibility: hidden; }
.card--drag { box-shadow: var(--shadow-3), inset 3px 0 0 var(--cat) !important; transform: rotate(1.5deg); cursor: grabbing; }
.sortable-fallback { opacity: 1 !important; }
.card--flash { animation: flash 900ms var(--ease); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--brand-soft), inset 3px 0 0 var(--cat); border-color: var(--brand); } }

/* Bouton flottant (mobile) et bandeau hors ligne */
.fab { display: none; }
.offline-bar {
  position: fixed; z-index: 80; left: 50%; translate: -50% 0;
  top: calc(12px + var(--safe-top));
  display: flex; align-items: center; gap: 10px;
  width: max-content; max-width: calc(100vw - 24px);
  padding: 10px 14px; border-radius: 12px;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  font-size: 13.5px; font-weight: 650;
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(10px);
}
.offline-bar .i { width: 18px; height: 18px; }

/* 7. Fenêtres (dialog natif) -------------------------------------- */
.sheet {
  width: min(600px, calc(100vw - 32px));
  max-height: min(860px, calc(100dvh - 48px));
  padding: 0; margin: auto;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.sheet--sm { width: min(460px, calc(100vw - 32px)); }
.sheet--confirm { width: min(400px, calc(100vw - 32px)); }
.sheet::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet[open] { animation: sheet-in 240ms var(--ease); }
.sheet[open]::backdrop { animation: fade-in 240ms var(--ease); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }

.sheet-form { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 16px 6px 24px; }
.sheet-title { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.sheet-body { display: grid; gap: 18px; padding: 14px 24px 22px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-meta { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.sheet-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px calc(14px + var(--safe-bottom)) 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.sheet-foot-spacer { flex: 1; }

.confirm-body { justify-items: center; text-align: center; gap: 10px; padding-top: 28px; }
.confirm-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--danger-soft); color: var(--danger);
}
.confirm-text { color: var(--ink-2); font-size: 14.5px; overflow-wrap: anywhere; }
.confirm-text strong { color: var(--ink); }

/* 8. Authentification --------------------------------------------- */
.page-auth { background: var(--surface); }
.auth { display: grid; grid-template-columns: minmax(380px, 44%) 1fr; min-height: 100vh; min-height: 100dvh; }

.auth-aside {
  position: relative;
  display: flex; flex-direction: column;
  padding: calc(40px + var(--safe-top)) 48px 36px;
  background: #0D3326;
  color: #E7F3EE;
  overflow: hidden;
}
.brand--light .brand-mark { background: #2FB37F; color: #06261A; }
.auth-statement {
  margin-top: auto;
  font-size: clamp(30px, 3.2vw, 44px); line-height: 1.12; font-weight: 800; letter-spacing: -.035em;
  color: #FFFFFF;
  max-width: 15ch;
  text-wrap: balance;
}
.lanes {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin: 40px 0 auto;
  align-items: start;
}
.lane {
  display: grid; gap: 7px;
  padding: 12px 10px 14px;
  border-radius: 12px;
  border-top: 3px solid var(--lane);
  background: rgba(255, 255, 255, .05);
}
.lane-name { font-size: 12px; font-weight: 700; color: rgba(231, 243, 238, .7); margin-bottom: 2px; }
.lane-card { display: block; height: 22px; border-radius: 6px; background: rgba(255, 255, 255, .13); }
.lane-card.is-done { background: rgba(47, 179, 127, .38); }
.page-auth .lane { --st-todo: #E3A13B; --st-progress: #6C9BF5; --st-deploy: #A887F3; --st-done: #2FB37F; }
.auth-foot { margin-top: 28px; font-size: 13px; color: rgba(231, 243, 238, .55); font-weight: 600; }

.auth-main {
  display: flex; flex-direction: column;
  padding: calc(20px + var(--safe-top)) 24px calc(32px + var(--safe-bottom));
}
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.auth-card { width: 100%; max-width: 400px; margin: auto; padding: 32px 0; }
.auth-brand-mobile { display: none; margin-bottom: 28px; }
.auth-title { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.auth-lead { margin: 6px 0 26px; color: var(--ink-3); font-weight: 600; }
.auth-card .alert { margin-bottom: 18px; }
.auth-card .btn--primary { margin-top: 6px; }
.auth-switch { margin-top: 24px; color: var(--ink-2); font-size: 14.5px; }
.auth-switch a { color: var(--brand); font-weight: 700; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* 9. Responsive --------------------------------------------------- */
@media (max-width: 1180px) {
  :root { --sidebar-w: 236px; }
  .board { grid-template-columns: repeat(4, minmax(270px, 1fr)); }
}

/* Tablette et mobile : menu latéral escamotable */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 70; left: 0; top: 0; bottom: 0;
    width: min(300px, 86vw);
    transform: translateX(-102%);
    transition: transform 260ms var(--ease);
    box-shadow: var(--shadow-3);
  }
  .sidebar.is-open { transform: none; }
  .sidebar-close { display: inline-grid; }
  .scrim {
    position: fixed; inset: 0; z-index: 60;
    display: block; background: var(--backdrop);
    opacity: 0; pointer-events: none;
    transition: opacity 260ms var(--ease);
  }
  .scrim.is-open { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-grid; margin-left: -8px; }
  .main { padding-left: calc(20px + var(--safe-left)); padding-right: calc(20px + var(--safe-right)); }
  .cat-edit { opacity: 1; }
  .cat-link .cat-count { right: 44px; }
  .cat-item:hover .cat-count, .cat-item:focus-within .cat-count { opacity: 1; }
  .card-advance { opacity: 1; }
}

/* Mobile : une colonne à la fois, onglets et balayage */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .main { height: auto; min-height: 100dvh; padding: 0; }

  .topbar {
    position: sticky; top: 0; z-index: 40;
    flex-wrap: wrap; gap: 8px 10px;
    padding: calc(10px + var(--safe-top)) calc(14px + var(--safe-right)) 10px calc(14px + var(--safe-left));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  }
  .menu-btn { margin-left: -6px; }
  .topbar-title h1 { font-size: 19px; }
  .topbar-title p { font-size: 12.5px; }
  .topbar-new { display: none; }
  .search { order: 3; width: 100%; }
  .search-input { height: 42px; font-size: 16px; }
  .search-kbd { display: none; }

  .pipeline { padding: 6px 16px 12px; }
  .pipeline-head { margin-bottom: 8px; }
  .pipeline-legend { display: none; }

  .tabs {
    position: sticky; z-index: 30;
    top: var(--topbar-h, 118px);
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
    margin: 0 12px 10px; padding: 4px;
    border-radius: 12px; background: var(--surface-3);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 46px; padding: 4px 2px;
    border: 0; border-radius: 9px; background: transparent;
    font-size: 12px; font-weight: 700; color: var(--ink-2); line-height: 1.2;
  }
  .tab-count { font-size: 15px; font-weight: 800; color: var(--ink); }
  .tab[aria-selected="true"] { background: var(--surface); box-shadow: var(--shadow-1); color: var(--ink); }
  .tab[aria-selected="true"] .tab-count { color: var(--tab-color, var(--brand)); }
  .tab[data-tab="todo"] { --tab-color: var(--st-todo); }
  .tab[data-tab="in_progress"] { --tab-color: var(--st-progress); }
  .tab[data-tab="deploy"] { --tab-color: var(--st-deploy); }
  .tab[data-tab="done"] { --tab-color: var(--st-done); }

  .board {
    display: flex; gap: 12px;
    padding: 0 16px calc(104px + var(--safe-bottom));
    overflow-x: auto; overflow-y: visible;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 16px;
    scrollbar-width: none;
    align-items: flex-start;
  }
  .board::-webkit-scrollbar { display: none; }
  .col { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; }
  .col-head { display: none; }
  .col-body { overflow: visible; padding: 10px; min-height: 50vh; }

  .card { padding: 13px 13px 12px 15px; }
  .card-title { font-size: 15px; padding-right: 38px; }
  .card-advance { width: 34px; height: 34px; top: 8px; right: 8px; }

  .fab {
    position: fixed; z-index: 50;
    right: calc(18px + var(--safe-right)); bottom: calc(20px + var(--safe-bottom));
    width: 58px; height: 58px; border-radius: 18px;
    display: grid; place-items: center;
    border: 0; background: var(--brand); color: var(--on-brand);
    box-shadow: 0 12px 28px -8px color-mix(in srgb, var(--brand) 70%, transparent), var(--shadow-2);
  }
  .fab .i { width: 26px; height: 26px; stroke-width: 2.4; }
  .toasts { bottom: calc(92px + var(--safe-bottom)); }

  /* Fenêtres en panneau qui monte du bas */
  .sheet, .sheet--sm {
    width: 100%; max-width: 100%;
    max-height: calc(100dvh - 24px - var(--safe-top));
    margin: auto 0 0;
    border-radius: 20px 20px 0 0; border-bottom: 0;
  }
  .sheet[open] { animation: sheet-up 300ms var(--ease); }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  .sheet-head { padding: 10px 12px 2px 20px; position: relative; }
  .sheet-head::before {
    content: ""; position: absolute; top: 6px; left: 50%; translate: -50% 0;
    width: 40px; height: 4px; border-radius: 4px; background: var(--line-2);
  }
  .sheet-head .sheet-title { padding-top: 12px; }
  .sheet-body { padding: 12px 20px 20px; }
  .field-row { grid-template-columns: 1fr; }
  .segmented { grid-template-columns: 1fr 1fr; }
  .input { font-size: 16px; } /* évite le zoom automatique d'iOS */
  .sheet--confirm { width: 100%; }
  .sheet-foot .btn { height: 46px; }
  .sheet-foot .btn--ghost { display: none; }
  .sheet-foot .btn--primary, .sheet-foot .btn--danger { flex: 1; }
  .sheet-foot-spacer { display: none; }

  /* Authentification */
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-brand-mobile { display: inline-flex; }
  .auth-card { padding: 16px 4px; }
  .auth-top .btn span { display: inline; }
}

@media (max-width: 380px) {
  .tab { font-size: 11px; }
  .auth-title { font-size: 26px; }
}

/* Application installée : marge pour l'encoche sur iOS */
@media (display-mode: standalone) {
  .auth-top .btn { display: none; }
}

@media (hover: none) {
  .card-advance { opacity: 1; }
  .cat-edit { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar, .topbar .search, .topbar-new, .fab, .tabs, .card-advance, .col-add { display: none !important; }
  .app { display: block; }
  .main { height: auto; padding: 0; }
  .board { display: grid; grid-template-columns: repeat(4, 1fr); overflow: visible; }
  .col-body { overflow: visible; }
}
