/* Reminder — mobile d'abord, puis tablette et ordinateur */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #16191f;
  --muted: #5f6673;
  --border: #dde1e7;
  --accent: #1055c9;
  --accent-text: #ffffff;
  --late: #c62828;
  --late-bg: #fdecec;
  --near: #1e8a46;
  --near-bg: #e8f6ed;
  --neutral: #8a919c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --gutter: 16px;
  color-scheme: light dark;
}
/* Mode nuit : automatique (réglage du navigateur), sauf choix explicite jour / nuit (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318;
    --surface: #1b1e25;
    --surface-2: #252932;
    --text: #eceef2;
    --muted: #a0a7b3;
    --border: #2f343e;
    --accent: #5b8ff0;
    --accent-text: #0b1020;
    --late: #ff6b6b;
    --late-bg: #3a1d20;
    --near: #4cc97a;
    --near-bg: #17301f;
    --neutral: #7d8592;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111318;
  --surface: #1b1e25;
  --surface-2: #252932;
  --text: #eceef2;
  --muted: #a0a7b3;
  --border: #2f343e;
  --accent: #5b8ff0;
  --accent-text: #0b1020;
  --late: #ff6b6b;
  --late-bg: #3a1d20;
  --near: #4cc97a;
  --near-bg: #17301f;
  --neutral: #7d8592;
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-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;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

/* --- barre du haut --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.topnav { display: flex; gap: 4px; align-items: center; }
.topnav a, .topnav button {
  background: none; border: 0; padding: 8px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; cursor: pointer; font-size: .95rem;
}
.topnav .theme-btn { font-size: 1.1rem; padding: 8px; }
.topnav a[aria-current="page"] { color: var(--text); font-weight: 600; background: var(--surface-2); }

/* --- page --- */
.page { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px var(--gutter) 96px; outline: none; }
h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 8px; }
h2.late { color: var(--late); }
h3 { font-size: .95rem; margin: 14px 0 6px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .875rem; }

/* --- cartes et formulaires --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 24px auto; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .field .label { font-weight: 600; font-size: .95rem; }
.hint { font-size: .85rem; color: var(--muted); }
input[type=text], input[type=email], input[type=number], input[type=date], select {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); min-height: 48px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
input.code { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.check { display: flex; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.error { color: var(--late); font-size: .9rem; min-height: 1.2em; margin: 4px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text); font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--late); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.actions .btn { flex: 1 1 140px; }

/* --- étiquettes --- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; min-height: 36px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: .9rem; cursor: pointer; color: var(--text);
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip.static { cursor: default; min-height: 0; padding: 2px 10px; font-size: .8rem; background: var(--surface-2); border: 0; }
.filters { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; margin: 0 calc(-1 * var(--gutter)); padding-inline: var(--gutter); }

/* --- planning --- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--neutral);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.task.late { border-left-color: var(--late); background: var(--late-bg); }
.task.near { border-left-color: var(--near); }
.task.today { border-left-color: var(--accent); }
.task-body { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.task-name { font-weight: 600; overflow-wrap: anywhere; }
.task-meta { font-size: .85rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.task-meta .late { color: var(--late); font-weight: 600; }
.task-meta .near { color: var(--near); font-weight: 600; }
.done-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface); cursor: pointer;
  display: grid; place-items: center; color: var(--muted); font-size: 1.2rem;
}
.done-btn:hover { border-color: var(--near); color: var(--near); }
.shared-icon { font-size: .8rem; }
.empty { padding: 32px 16px; text-align: center; }

.fab {
  position: fixed; right: max(var(--gutter), env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom));
  min-height: 56px; padding: 0 22px; border-radius: 28px; border: 0;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 1rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.2); text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}

/* --- fiche --- */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.history li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.history .ok { color: var(--near); }
.history .ko { color: var(--late); }

/* --- boîte de dialogue et message --- */
dialog { border: 0; border-radius: 16px; padding: 22px; width: min(92vw, 420px); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 8px; }
dialog .actions { flex-direction: column; }
dialog .actions .btn { flex: none; width: 100%; }
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #1f2430; color: #fff; padding: 12px 18px; border-radius: 10px; max-width: calc(100vw - 32px);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.ad-slot { height: 50px; }
.foot { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 8px; font-size: .75rem; color: var(--muted); }
.lang-select { width: auto; min-height: 32px; padding: 4px 8px; font-size: .8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }

/* --- tablette et ordinateur --- */
@media (min-width: 768px) {
  :root { --gutter: 24px; }
  .page { padding-top: 24px; }
  h1 { font-size: 1.6rem; }
  .task { padding: 14px 16px 14px 18px; }
}
