:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --text: #1f2624;
  --muted: #6b7472;
  --border: #e2ddd4;
  --accent: #2f7d6d;
  --accent-soft: #dcefe9;
  --on-accent: #ffffff;
  --late: #b4492f;
  --late-soft: #f8e4dd;
  --evening: #4f56b8;
  --evening-soft: #e4e5f7;
  --warn-soft: #fbf0d4;
  --shadow: 0 1px 2px rgba(30, 30, 20, .06), 0 4px 14px rgba(30, 30, 20, .05);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151a19;
    --surface: #1e2423;
    --surface-2: #262d2c;
    --text: #e8ecea;
    --muted: #9aa5a2;
    --border: #2f3836;
    --accent: #5cc0a8;
    --accent-soft: #1f3a34;
    --on-accent: #0d1f1b;
    --late: #f08a6c;
    --late-soft: #3d241d;
    --evening: #9aa0f2;
    --evening-soft: #262849;
    --warn-soft: #3a3220;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151a19; --surface: #1e2423; --surface-2: #262d2c; --text: #e8ecea; --muted: #9aa5a2;
  --border: #2f3836; --accent: #5cc0a8; --accent-soft: #1f3a34; --on-accent: #0d1f1b; --late: #f08a6c;
  --late-soft: #3d241d; --evening: #9aa0f2; --evening-soft: #262849; --warn-soft: #3a3220; --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -moz-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 1rem; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; word-break: break-all; }

/* ---------- En-tête ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.who-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 12px 6px 8px; cursor: pointer; font-size: .9rem;
}

.view { max-width: 680px; margin: 0 auto; padding: 8px 16px 24px; }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Navigation ---------- */
.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 11px; line-height: 1.3; padding: 4px 0; border-radius: 10px; min-width: 0; width: 100%;
}
.tabs .label { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs .ico { flex: none; }
.top-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
.icon-btn.active { color: var(--accent); }
@media (max-width: 340px) { .brand span { display: none; } }
.tabs button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.ico { display: inline-flex; width: 22px; height: 22px; }
.ico svg { width: 100%; height: 100%; }

/* ---------- Blocs ---------- */
.hero { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.hero .row.between { flex-wrap: nowrap; align-items: flex-start; }
.hero .row.between > :first-child { min-width: 0; }
.hero .row.between > .btn { flex: none; }
.eyebrow { color: var(--muted); font-size: .9rem; text-transform: capitalize; }
.lead { color: var(--muted); }
.badge {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .85rem; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.badge.off { background: var(--warn-soft); color: var(--text); }
.badge .ico { width: 16px; height: 16px; }

.group { display: flex; flex-direction: column; gap: 8px; }
.group-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.group-head h2 { display: flex; align-items: center; gap: 6px; }
.group-head h2 .ico { width: 18px; height: 18px; }
.group-head .count { color: var(--muted); font-size: .9rem; }
.group-head .note { color: var(--muted); font-size: .82rem; width: 100%; }
.group.late h2 { color: var(--late); }
.group.evening h2 { color: var(--evening); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.task {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
  transition: opacity .25s, transform .25s;
}
.group.late .task { border-left: 4px solid var(--late); }
.group.evening .task { border-left: 4px solid var(--evening); }
.task.done { opacity: .35; transform: scale(.98); }
.task.done .title { text-decoration: line-through; }
.task .body { flex: 1; min-width: 0; cursor: pointer; }
.task .title { font-weight: 600; overflow-wrap: anywhere; }
.task .notes { color: var(--muted); font-size: .9rem; margin-top: 2px; white-space: pre-line; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: .82rem; color: var(--muted); }
.chip { padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-weight: 600; }
.chip.late { background: var(--late-soft); color: var(--late); }
.chip.evening { background: var(--evening-soft); color: var(--evening); }
.who { display: inline-flex; align-items: center; gap: 5px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

.check {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--accent); background: transparent; color: transparent;
  display: grid; place-items: center; cursor: pointer; padding: 6px;
  transition: background .15s, color .15s;
}
.check:hover, .check:focus-visible { background: var(--accent-soft); color: var(--accent); }
.task.done .check { background: var(--accent); color: var(--on-accent); }
.group.late .check { border-color: var(--late); }
.group.evening .check { border-color: var(--evening); }

.icon-btn {
  flex: none; border: 0; background: none; cursor: pointer; color: var(--muted);
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; padding: 6px;
}
.icon-btn:hover { background: var(--surface-2); }

.empty {
  text-align: center; padding: 32px 16px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty .big { font-size: 2rem; }
.empty strong { color: var(--text); font-size: 1.05rem; }

.hint {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warn-soft); border-radius: var(--radius); padding: 12px 14px; font-size: .92rem;
}

/* ---------- Boutons & formulaires ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 12px;
  padding: 10px 16px; cursor: pointer; font-weight: 600; min-height: 44px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--late); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: .9rem; }
.btn .ico { width: 18px; height: 18px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; cursor: pointer; font-size: .9rem; }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}
.card h2 { font-size: 1.1rem; }
.card .sub { color: var(--muted); font-size: .9rem; margin-top: -8px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: .88rem; font-weight: 600; }
.field small, .help { color: var(--muted); font-size: .82rem; }
input[type="text"], input[type="search"], input[type="date"], input[type="time"], input[type="number"],
input[type="password"], input[type="url"], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
input[type="number"] { width: 84px; }
input[type="color"] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
textarea { min-height: 70px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline input[type="number"] { flex: none; }
.inline select { width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

.toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.toggle input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.toggle b { display: block; font-weight: 600; font-size: .95rem; }

.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.days span {
  display: grid; place-items: center; width: 42px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); font-size: .88rem; font-weight: 600; background: var(--bg);
}
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.days.quick span { width: auto; padding: 0 12px; }
.days input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.simple-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.simple-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.simple-list li:first-child { border-top: 0; }
.simple-list .grow { flex: 1; min-width: 0; }
.simple-list .grow small { display: block; color: var(--muted); }

.task-card { cursor: pointer; }

.hist-day { font-size: .85rem; color: var(--muted); text-transform: capitalize; margin-top: 6px; }
.hist { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.hist .badge-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; padding: 6px; }
.hist .done { background: var(--accent-soft); color: var(--accent); }
.hist .skipped { background: var(--surface-2); color: var(--muted); }
.hist .missed { background: var(--late-soft); color: var(--late); }
.hist .grow { flex: 1; min-width: 0; }
.hist .grow small { display: block; color: var(--muted); font-size: .82rem; }

.status { font-size: .9rem; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
.status.bad { background: var(--late-soft); }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
details summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
details[open] summary { margin-bottom: 12px; }

/* ---------- Fenêtre modale ---------- */
.modal {
  border: 0; padding: 0; background: var(--surface); color: var(--text);
  width: min(560px, 100vw); max-height: 92vh; border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.modal::backdrop { background: rgba(10, 15, 14, .45); }
.modal > form, .modal > .sheet { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.modal h2 { font-size: 1.2rem; }
@media (max-width: 600px) {
  .modal { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; }
}
.sheet .btn { width: 100%; justify-content: flex-start; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 10px 14px;
  max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-size: .92rem;
}
.toast button { border: 0; background: none; color: var(--accent-soft); font-weight: 700; cursor: pointer; padding: 4px; }

.login { max-width: 360px; margin: 12vh auto 0; }

/* ---------- Durées & listes ---------- */
.chip.soft { display: inline-flex; align-items: center; gap: 3px; background: var(--accent-soft); color: var(--accent); }
.chip .ico { width: 13px; height: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet .chips .btn, .sheet .row .btn, .sheet .inline .btn { width: auto; justify-content: center; }
.sheet .inline input[type="number"] { width: 96px; }
.group-head .spacer { flex: 1; }
.group-head.has-actions { flex-wrap: nowrap; align-items: center; }
.group-head.has-actions h2 { min-width: 0; }
.group-head.has-actions .count { white-space: nowrap; }
.group-head .icon-btn { width: 30px; height: 30px; padding: 5px; }
.list-ico {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--evening-soft); color: var(--evening); padding: 7px;
}
.icon-btn.fwd { transform: rotate(180deg); }
.grip {
  flex: none; width: 24px; height: 34px; margin-left: -6px; padding: 5px 0;
  display: grid; place-items: center; border: 0; background: none; color: var(--muted);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.task.dragging { position: relative; z-index: 2; box-shadow: 0 8px 24px rgba(0, 0, 0, .22); }
.task.dragging .grip { cursor: grabbing; }
button.hist { width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; }
button.hist:hover { background: var(--surface-2); }

/* ---------- Impression d'une liste ---------- */
.print-area { display: none; }
.print-area .n { white-space: pre-line; }
@media print {
  body { background: #fff; color: #000; padding: 0; font-size: 12pt; }
  body > *:not(#print) { display: none !important; }
  .print-area { display: block; }
  .print-area h1 { font-size: 20pt; margin-bottom: 4pt; }
  .print-sub { color: #444; margin-bottom: 14pt; }
  .print-area table { width: 100%; border-collapse: collapse; }
  .print-area th { text-align: left; font-size: 10pt; color: #555; border-bottom: 1.5pt solid #000; padding: 4pt 6pt; }
  .print-area td { border-bottom: 0.75pt solid #bbb; padding: 9pt 6pt; vertical-align: top; }
  .print-area td.box { width: 22pt; font-size: 16pt; line-height: 1; }
  .print-area td.dur { width: 70pt; white-space: nowrap; color: #333; }
  .print-area .n { font-size: 10pt; color: #444; margin-top: 2pt; }
  .print-notes { margin-top: 22pt; min-height: 120pt; border: 0.75pt solid #999; border-radius: 6pt; padding: 8pt; color: #555; }
  @page { margin: 16mm; }
}
