:root {
  --gold: #E0A419;
  --gold-soft: #FBF3E0;
  --black: #000000;
  --ink: #1a1a1a;
  --muted: #8a8a8a;
  --line: #ececec;
  --bg: #ffffff;
  --card: #ffffff;
  --done: #b8b8b8;
  --red: #C5221F;
  --red-soft: #F4B4AD;
  --red-text: #A50E0E;
  --orange: #E8710A;
  --orange-soft: #FEF1E6;
  --green: #1E8E3E;
  --green-soft: #E6F4EA;
  /* Fonds de carte, plus légers que les étiquettes */
  --red-tint: #FAD6D2;
  --orange-tint: #FFF9F3;
  --green-tint: #F4FAF6;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: 'Josefin Sans', system-ui, sans-serif;
  font-weight: 500;
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
h1, h2, h3, .wordmark { font-family: 'Orbitron', sans-serif; font-weight: 700; letter-spacing: .04em; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* En-tête */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { height: 30px; width: 30px; }
.wordmark { font-size: 18px; color: var(--black); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.icon-btn:active { background: var(--gold-soft); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 12px 16px calc(120px + var(--safe-b)); max-width: 640px; margin: 0 auto; }

/* Filtres catégorie : gros boutons */
.cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cat {
  min-height: 56px; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: var(--radius);
  font-weight: 700; font-size: 16px; text-align: center;
  background: var(--card);
  transition: background .15s, border-color .15s;
}
.cat .n { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
.cat.on { background: var(--black); border-color: var(--black); color: #fff; }
.cat.on .n { color: var(--gold); }
.cats.small .cat { min-height: 48px; }
.cats.small .cat.on { background: var(--gold); border-color: var(--gold); color: var(--black); }

/* Contrôle segmenté */
.seg {
  display: flex; margin-top: 12px; padding: 4px; gap: 4px;
  background: #f4f4f4; border-radius: 14px;
}
.seg button {
  flex: 1; min-height: 44px; border-radius: 10px; font-weight: 700; font-size: 15px; color: #555;
}
.seg button.on { background: #fff; color: var(--black); box-shadow: 0 1px 4px rgba(0,0,0,.12); }

.count { color: var(--muted); font-size: 14px; margin: 16px 2px 8px; }

/* Liste */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 12px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card);
}
.item:active { background: #fafafa; }
.check {
  flex: none; width: 44px; height: 44px; margin: -4px 0 0 -4px;
  display: grid; place-items: center;
}
.check span {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #c9c9c9; background: #fff; display: grid; place-items: center;
  transition: all .15s;
}
.check.prog span { border-color: var(--gold); border-style: dashed; }
.check.on span { background: var(--gold); border-color: var(--gold); }
.check.on span::after {
  content: ''; width: 5px; height: 10px; margin-top: -2px;
  border: solid #000; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.body { flex: 1; min-width: 0; }
.sujet { font-weight: 700; font-size: 17px; }
.preview {
  color: #555; font-size: 15px; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--muted); align-items: center; }
.tag { padding: 3px 8px; border-radius: 8px; background: #f4f4f4; color: #444; }
/* Priorités : rouge = urgent, orange = moyen, vert = faible */
.p { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 8px; font-weight: 700; }
.p::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.p1 { background: var(--red-soft); color: var(--red-text); }
.p2 { background: var(--orange-soft); color: var(--orange); }
.p3 { background: var(--green-soft); color: var(--green); }
.item.pr1 { border-left: 6px solid var(--red); background: var(--red-tint); }
.item.pr2 { border-left: 6px solid var(--orange); background: var(--orange-tint); }
.item.pr3 { border-left: 6px solid var(--green); background: var(--green-tint); }
.item.done { border-left-color: var(--line); background: var(--card); }
.seg.prio button[data-prio="1"].on { background: var(--red); color: #fff; }
.seg.prio button[data-prio="2"].on { background: var(--orange); color: #fff; }
.seg.prio button[data-prio="3"].on { background: var(--green); color: #fff; }
.st-prog { background: var(--gold-soft); color: #8a6100; }
.item.done .sujet, .item.done .preview { color: var(--done); text-decoration: line-through; }

.empty { text-align: center; color: var(--muted); margin-top: 40px; }

/* Bouton flottant */
.fab {
  position: fixed; z-index: 20;
  right: 20px; bottom: calc(24px + var(--safe-b));
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--gold); color: var(--black);
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(224,164,25,.45);
}
.fab:active { transform: scale(.95); }

/* Panneaux plein écran */
.sheet {
  position: fixed; inset: 0; z-index: 30;
  background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet-body { max-width: 640px; margin: 0 auto; padding: calc(10px + var(--safe-t)) 16px calc(32px + var(--safe-b)); }
.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 52px; margin-bottom: 8px;
}
.sheet-head h2 { font-size: 16px; margin: 0; }
.sheet-head > :first-child { justify-self: start; }
.text-btn { min-height: 44px; padding: 0 4px; color: #8a6100; font-weight: 700; }
.text-btn.center { display: block; margin: 16px auto 0; }

.lbl { display: block; font-weight: 700; font-size: 14px; margin: 18px 2px 8px; }
.muted { color: var(--muted); font-weight: 500; }
.input {
  width: 100%; padding: 14px; font: inherit; font-size: 17px;
  border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink);
  -webkit-appearance: none;
}
.input:focus { outline: none; border-color: var(--gold); }
#new-cat-wrap { margin-top: 10px; }

.mic {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 100%; margin-top: 22px; padding: 22px;
  border-radius: 20px; border: 2px dashed var(--gold); background: var(--gold-soft);
  font-weight: 700;
}
.mic.rec { background: var(--black); color: var(--gold); border-style: solid; border-color: var(--black); }
.mic.rec svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }
.hint { color: var(--muted); font-size: 14px; text-align: center; margin: 8px 0 0; }
.hint.left { text-align: left; }

.btn-primary {
  display: block; width: 100%; min-height: 58px; margin-top: 26px;
  border-radius: 16px; background: var(--black); color: #fff;
  font-family: 'Orbitron', sans-serif; font-weight: 700; letter-spacing: .05em; font-size: 15px;
}
.btn-primary:active { opacity: .85; }
.btn-primary[disabled] { opacity: .5; }
.btn-primary.gold { background: var(--gold); color: var(--black); }

/* Détail */
.d-cat { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.d-title { font-family: 'Orbitron', sans-serif; font-size: 22px; line-height: 1.3; margin: 6px 0 14px; }
.d-content { font-size: 18px; line-height: 1.5; white-space: pre-wrap; margin: 0 0 20px; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.d-cell { background: #f7f7f7; border-radius: 12px; padding: 10px 12px; }
.d-cell small { display: block; color: var(--muted); font-size: 12px; }
.d-cell b { font-size: 16px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(110px + var(--safe-b)); z-index: 50;
  margin: 0 auto; max-width: 420px;
  padding: 14px 16px; border-radius: 14px;
  background: var(--black); color: #fff; text-align: center; font-size: 15px;
}
.toast.err { background: #b3261e; }
