:root {
  --ink: #172033;
  --muted: #687286;
  --paper: #f7f5f0;
  --line: rgba(23, 32, 51, .12);
  --shadow: 0 18px 45px rgba(23,32,51,.12), 0 3px 10px rgba(23,32,51,.07);
  --radius: 22px;
  --cell-urgent-court: rgba(214, 88, 63, .20);
  --cell-urgent-long:  rgba(214, 130, 63, .18);
  --cell-calme-court:  rgba(214, 178, 63, .16);
  --cell-calme-long:   rgba(120, 150, 130, .16);
  --border-urgent-court: rgba(214, 88, 63, .38);
  --border-urgent-long:  rgba(214, 130, 63, .32);
  --border-calme-court:  rgba(214, 178, 63, .30);
  --border-calme-long:   rgba(120, 150, 130, .30);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--ink); min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(241,174,96,.20), transparent 26rem),
    radial-gradient(circle at 100% 88%, rgba(109,151,190,.18), transparent 31rem),
    var(--paper);
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .26; z-index: 0;
  background-image: radial-gradient(rgba(23,32,51,.16) .65px, transparent .65px);
  background-size: 9px 9px; mask-image: linear-gradient(135deg, black, transparent 75%);
}
.shell { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 52px 0 64px; position: relative; z-index: 1; }

/* ── En-têtes ─────────────────────────────────────────────── */
.app-header { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 10px; color: #b65c39; font-size: .75rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.45rem, 6vw, 5.2rem); line-height: .94; letter-spacing: -.055em; font-weight: 600; }
.header-right { text-align: right; }
.intro { max-width: 360px; margin: 0 0 14px auto; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.legend { display: flex; align-items: center; gap: 8px; justify-content: flex-end; color: var(--muted); font-size: .78rem; margin-top: 12px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: #b65c39; }
.topnav { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

/* ── Boutons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 17px; border-radius: 11px;
  border: 1px solid rgba(23,32,51,.16); background: rgba(255,255,255,.72); color: var(--ink);
  font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.btn:hover { transform: translateY(-1px); background: #fff; box-shadow: 0 6px 14px rgba(23,32,51,.11); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(23,32,51,.28); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #24314c; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: #a63b26; border-color: rgba(166,59,38,.35); }
.btn.danger:hover { background: rgba(166,59,38,.08); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Légende priorités ────────────────────────────────────── */
.priority-legend {
  display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 28px; padding: 14px 18px;
  background: rgba(255,255,255,.55); border: 1px solid rgba(23,32,51,.09);
  border-radius: 14px; font-size: .76rem; color: var(--muted);
}
.priority-legend-item { display: flex; align-items: center; gap: 7px; }
.priority-swatch { width: 13px; height: 13px; border-radius: 4px; flex: 0 0 auto; }
.priority-swatch.pl-1 { background: var(--cell-urgent-court); border: 1px solid var(--border-urgent-court); }
.priority-swatch.pl-2 { background: var(--cell-urgent-long);  border: 1px solid var(--border-urgent-long); }
.priority-swatch.pl-3 { background: var(--cell-calme-court);  border: 1px solid var(--border-calme-court); }
.priority-swatch.pl-4 { background: var(--cell-calme-long);   border: 1px solid var(--border-calme-long); }

/* ── Matrice ──────────────────────────────────────────────── */
.matrix-wrap { display: grid; grid-template-columns: 44px minmax(0,1fr); grid-template-rows: 28px auto; gap: 0 16px; }
.axis { color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.axis-x { grid-column: 2; display: flex; justify-content: space-between; padding: 0 14px; }
.axis-y { grid-column: 1; grid-row: 2; writing-mode: vertical-rl; transform: rotate(180deg); display: flex; justify-content: space-between; align-items: center; }
.grid { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.quadrant {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 22px;
  box-shadow: var(--shadow); min-height: 260px; opacity: 0; animation: rise .5s ease forwards;
}
.q1 { background: linear-gradient(135deg, #f2d6cb 0%, #f8e7e0 55%, #f1d5ca 100%); animation-delay: .05s; }
.q2 { background: linear-gradient(135deg, #e7dfc9 0%, #f2ecdb 55%, #e8e0ca 100%); animation-delay: .12s; }
.q3 { background: linear-gradient(135deg, #c9dce7 0%, #e0edf0 55%, #cadde7 100%); animation-delay: .19s; }
.q4 { background: linear-gradient(135deg, #e7e6e0 0%, #f2f1ec 55%, #e9e8e2 100%); animation-delay: .26s; }
.q-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.q-number { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .82rem; font-weight: 700; flex: 0 0 auto; }
.q-title { margin: 0; font-size: 1.32rem; font-weight: 700; line-height: 1.15; }
.q-title small { display: block; margin-top: 3px; font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.sub-matrix-wrap { display: grid; grid-template-columns: 26px minmax(0,1fr); grid-template-rows: 20px auto; gap: 0 8px; }
.sub-axis { color: var(--muted); font-size: .58rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.sub-axis-x { grid-column: 2; display: flex; justify-content: space-between; padding: 0 6px; }
.sub-axis-y { grid-column: 1; grid-row: 2; writing-mode: vertical-rl; transform: rotate(180deg); display: flex; justify-content: space-between; align-items: center; }
.sub-grid { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sub-cell { border: 1px solid; border-radius: 14px; padding: 10px 10px 8px; min-height: 76px; transition: outline .15s ease, background-color .15s ease; }
.sub-cell.cell-urgent-court { background: var(--cell-urgent-court); border-color: var(--border-urgent-court); }
.sub-cell.cell-urgent-long  { background: var(--cell-urgent-long);  border-color: var(--border-urgent-long); }
.sub-cell.cell-calme-court  { background: var(--cell-calme-court);  border-color: var(--border-calme-court); }
.sub-cell.cell-calme-long   { background: var(--cell-calme-long);   border-color: var(--border-calme-long); }
.sub-cell-label { margin: 0 0 8px; font-size: .62rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink); opacity: .68; }
.sub-cell.drop-target { outline: 2px dashed rgba(23,32,51,.52); outline-offset: 3px; background-color: rgba(255,255,255,.30); }

/* ── Tâches ───────────────────────────────────────────────── */
.tasks { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tasks .empty { font-size: .68rem; color: var(--muted); opacity: .55; padding: 2px 4px; }
.task {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px;
  border: 1px solid rgba(23,32,51,.09); border-radius: 10px; color: var(--ink);
  background: rgba(255,255,255,.72); box-shadow: 0 3px 8px rgba(23,32,51,.06);
  text-align: left; font: inherit; font-size: .8rem; line-height: 1.2; cursor: pointer;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease, opacity .2s ease;
  flex-wrap: wrap; position: relative;
}
.task[draggable="true"] { cursor: grab; }
.task.dragging { opacity: .35; transform: scale(.98); }
.task:hover, .task:focus-visible { transform: translateY(-2px); background: rgba(255,255,255,.95); box-shadow: 0 6px 13px rgba(23,32,51,.11); outline: none; }
.task:focus-visible { box-shadow: 0 0 0 3px rgba(23,32,51,.28), 0 6px 13px rgba(23,32,51,.11); }
.task.manual::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: rgba(23,32,51,.28); }
.check { display: grid; place-items: center; flex: 0 0 14px; width: 14px; height: 14px; border: 1.5px solid rgba(23,32,51,.38); border-radius: 4px; color: #fff; font-size: .58rem; transition: background .2s ease, border .2s ease; }
.task.done { opacity: .55; background: repeating-linear-gradient(135deg, rgba(85,112,95,.10) 0 7px, rgba(255,255,255,.55) 7px 14px); border-style: dashed; border-color: rgba(85,112,95,.38); }
.task.done .task-title { text-decoration: line-through; }
.task.done .check { border-color: #55705f; background: #55705f; }
.task.done .check::after { content: "✓"; }
.task-title { min-width: 0; flex: 1; }
.edit-dot { flex: 0 0 auto; padding: 0 4px; color: var(--muted); font-weight: 700; letter-spacing: .05em; border-radius: 6px; opacity: 0; transition: opacity .15s ease, background .15s ease; }
.task:hover .edit-dot, .edit-dot:focus-visible { opacity: 1; }
.edit-dot:hover { background: rgba(23,32,51,.10); }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 0 22px; font-size: .62rem; color: var(--muted); line-height: 1.25; width: 100%; }

footer { display: flex; justify-content: space-between; gap: 18px; margin: 20px 5px 0 64px; color: var(--muted); font-size: .78rem; }

/* ── Messages ─────────────────────────────────────────────── */
.flash {
  margin: 0 0 20px; padding: 12px 16px; border-radius: 12px;
  font-size: .84rem; line-height: 1.45; border: 1px solid transparent;
  animation: rise .3s ease;
}
.flash.err { background: rgba(214,88,63,.12); border-color: rgba(214,88,63,.34); color: #8f3722; }
.flash.ok  { background: rgba(85,112,95,.13); border-color: rgba(85,112,95,.34); color: #3c5548; }
.flash.info{ background: rgba(109,151,190,.14); border-color: rgba(109,151,190,.34); color: #2f4a66; }

/* ── Fenêtre modale ───────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgba(23,32,51,.44); backdrop-filter: blur(3px);
  animation: fade .2s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px 30px 26px; box-shadow: var(--shadow); animation: rise .28s ease;
}
.panel-title {
  margin: 0 0 22px; font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem; font-weight: 600; letter-spacing: -.03em;
}

/* ── Formulaires ──────────────────────────────────────────── */
form label {
  display: block; margin-bottom: 16px;
  font-size: .74rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
form label .opt { font-weight: 600; letter-spacing: 0; text-transform: none; opacity: .75; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"] {
  display: block; width: 100%; margin-top: 7px; padding: 11px 13px;
  border: 1px solid rgba(23,32,51,.18); border-radius: 11px;
  background: rgba(255,255,255,.80); color: var(--ink);
  font: inherit; font-size: .92rem; font-weight: 400; letter-spacing: normal; text-transform: none;
  transition: border .18s ease, box-shadow .18s ease, background .18s ease;
}
input:focus {
  outline: none; background: #fff;
  border-color: rgba(23,32,51,.42); box-shadow: 0 0 0 3px rgba(23,32,51,.11);
}
input[disabled] { opacity: .45; cursor: not-allowed; }

fieldset { margin: 0 0 16px; padding: 0; border: 0; }
legend {
  padding: 0; margin-bottom: 9px;
  font-size: .74rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
legend .req { color: #b65c39; font-size: .66rem; letter-spacing: .06em; }

.deadline-set .row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.deadline-set .row input[type="date"] { flex: 1 1 190px; margin-top: 0; width: auto; }
.chk {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  font-size: .8rem; font-weight: 600; letter-spacing: 0;
  text-transform: none; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.chk input { width: 15px; height: 15px; accent-color: var(--ink); cursor: pointer; }

.hint { margin: 7px 0 0; font-size: .7rem; color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none; line-height: 1.4; }
.hint.scale { display: flex; justify-content: space-between; margin: -10px 0 18px; font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }

.range-label { margin-bottom: 8px; position: relative; }
.range-label output {
  position: absolute; right: 0; top: 0;
  font-size: .95rem; font-weight: 700; letter-spacing: -.01em;
  text-transform: none; color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; margin-top: 14px; padding: 0;
  border-radius: 99px; background: linear-gradient(90deg,
    rgba(120,150,130,.55) 0%, rgba(214,178,63,.60) 50%, rgba(214,88,63,.65) 100%);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--paper); border: 2.5px solid var(--ink);
  box-shadow: 0 2px 7px rgba(23,32,51,.26); cursor: grab;
  transition: transform .15s ease;
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.12); cursor: grabbing; }
input[type="range"]::-moz-range-thumb {
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--paper); border: 2.5px solid var(--ink);
  box-shadow: 0 2px 7px rgba(23,32,51,.26); cursor: grab;
}
input[type="range"]:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(23,32,51,.22); }

.radios { display: flex; gap: 9px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; margin: 0;
  padding: 10px 15px; border: 1px solid rgba(23,32,51,.18); border-radius: 11px;
  background: rgba(255,255,255,.70);
  font-size: .82rem; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--ink); cursor: pointer; transition: all .18s ease;
}
.pill input { accent-color: var(--ink); cursor: pointer; }
.pill:hover { background: #fff; }
.pill:has(input:checked) { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 1px var(--ink); }

.modal-actions { display: flex; align-items: center; gap: 9px; margin-top: 26px; flex-wrap: wrap; }
.modal-actions .spacer { flex: 1; }

/* ── Pages d'authentification ─────────────────────────────── */
.auth-shell {
  width: min(460px, calc(100% - 32px)); margin: 0 auto;
  padding: clamp(40px, 9vh, 92px) 0 60px; position: relative; z-index: 1;
}
.auth-card {
  background: rgba(255,255,255,.62); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 34px 32px 30px;
  box-shadow: var(--shadow); animation: rise .45s ease;
}
.auth-shell h1 { font-size: clamp(2rem, 8vw, 2.9rem); margin-bottom: 8px; }
.auth-sub { margin: 0 0 26px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: 13px 18px; font-size: .9rem; }
.auth-alt {
  margin: 22px 0 0; padding-top: 20px; border-top: 1px solid var(--line);
  text-align: center; font-size: .82rem; color: var(--muted);
}
.auth-alt a { color: var(--ink); font-weight: 600; text-decoration: none; border-bottom: 1px solid rgba(23,32,51,.28); }
.auth-alt a:hover { border-bottom-color: var(--ink); }
.tabs { display: flex; gap: 6px; margin-bottom: 26px; padding: 4px; background: rgba(23,32,51,.06); border-radius: 12px; }
.tabs button {
  flex: 1; padding: 10px; border: 0; border-radius: 9px; background: transparent;
  font: inherit; font-size: .84rem; font-weight: 700; color: var(--muted); cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.tabs button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 6px rgba(23,32,51,.10); }

.pw-meter { height: 5px; margin-top: 8px; border-radius: 99px; background: rgba(23,32,51,.12); overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .25s ease, background .25s ease; }
.pw-meter.s1 span { width: 25%;  background: #d6583f; }
.pw-meter.s2 span { width: 50%;  background: #d6823f; }
.pw-meter.s3 span { width: 75%;  background: #d6b23f; }
.pw-meter.s4 span { width: 100%; background: #55705f; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 620px); padding-top: 32px; }
  .app-header { display: block; margin-bottom: 25px; }
  .header-right { text-align: left; }
  .intro { max-width: 460px; margin: 17px 0 14px; }
  .topnav { justify-content: flex-start; }
  .legend { margin-top: 17px; justify-content: flex-start; }
  .priority-legend { gap: 10px 16px; font-size: .72rem; }
  .matrix-wrap { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .axis-y { display: none; }
  .axis-x { order: -1; justify-content: space-between; padding: 0 8px 14px; }
  .grid { grid-column: 1; grid-template-columns: 1fr; gap: 13px; }
  .quadrant { min-height: auto; padding: 20px 18px; }
  .sub-grid { grid-template-columns: 1fr; }
  .sub-axis-y { display: none; }
  .task-meta { margin-left: 22px; }
  .edit-dot { opacity: 1; }
  footer { margin-left: 5px; display: block; }
  footer span { display: block; margin-top: 6px; }
  .modal { padding: 24px 20px 20px; }
  .modal-actions .btn { flex: 1; justify-content: center; }
}


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