:root {
  color-scheme: dark;
  --bg: #150d08; --paper: #201710; --ink: #fdf7ea; --muted: #d6c6ab;
  --line: #8a6d52; --gold: #e9c25e; --blue: #a9c8f5; --spine: #382a1e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 "Raleway", -apple-system, system-ui, sans-serif; font-weight: 400; }
[hidden] { display: none !important; }
.serif { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 500; }
h1, h2 { margin: 0; }
.eyebrow { font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--muted); margin: 0; }
.err { color: #f0907f; margin: 0; min-height: 1.3em; }
.muted { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }

input { font: inherit; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: transparent; width: 100%; color: var(--ink); outline: none; }
input:focus { border-bottom-color: var(--ink); }
input::placeholder { color: var(--muted); }
button { font: inherit; border: 0; background: none; color: var(--ink); cursor: pointer; }
button.primary { background: var(--ink); color: var(--bg); border-radius: 999px; padding: 13px 22px;
  letter-spacing: .12em; text-transform: uppercase; font-size: 13px; font-weight: 500; }

/* Premier lancement */
#setup { padding: 90px 28px; max-width: 420px; margin: auto; display: grid; gap: 14px; }
#setup h1 { font-size: 56px; line-height: 1; }
.lead { color: var(--muted); margin: 0 0 8px; }
.who-pick { display: flex; gap: 10px; }
.who-pick button { flex: 1; padding: 14px; border: 1px solid var(--line); border-radius: 999px;
  font-family: "Cormorant Garamond", Georgia, serif; font-size: 22px; }
.who-pick button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
#setup .primary { margin-top: 10px; justify-self: start; }

#app { max-width: 520px; margin: auto; padding: calc(env(safe-area-inset-top) + 8px) 20px 60px; }
.gear { font-size: 22px; color: var(--muted); padding: 8px; }

/* Accueil : arche + étagère */
#home { position: relative; }
#home > .gear { position: absolute; right: -6px; top: 4px; z-index: 2; }
.arch { margin: 34px 0 0; padding: 100px 20px 34px; text-align: center;
  border: 1px solid var(--line); border-bottom: 0; border-radius: 50% 50% 0 0 / 170px 170px 0 0; }
.arch h1 { font-size: 30px; letter-spacing: .5em; margin: 14px 0 18px; padding-left: .5em; }
.quote { color: var(--blue); font-size: 19px; font-style: italic; margin: 0; line-height: 1.3; }
#banner { margin: 16px 0 0; padding: 12px 14px; border: 1px solid var(--line); font-size: 14px; background: var(--paper); }
#banner button { margin-top: 10px; }

.shelf { margin: 0; }
.spine { width: 8px; background: var(--spine); border-radius: 1px; flex: none; }
.book { flex: 0 0 24%; aspect-ratio: 2 / 3.1; position: relative; border-radius: 3px 5px 5px 3px;
  box-shadow: 2px 3px 8px rgba(0,0,0,.55), inset 4px 0 0 rgba(0,0,0,.12); color: #f4eddd; padding: 0;
  transition: transform .18s ease; }
.book:active { transform: translateY(-4px) scale(1.02); }
.book .frame { position: absolute; inset: 6px 6px 6px 10px; border: 1px solid rgba(244,237,221,.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 4px 2px; overflow: hidden; }
.book .name { font-family: "Cormorant Garamond", Georgia, serif; font-size: 12.5px; line-height: 1.05;
  letter-spacing: 0; text-transform: uppercase; font-weight: 400; }
.book.new .name { font-weight: 700; }
.book .orn { width: 16px; height: 1px; background: var(--gold); }
.book .count { font-size: 7.5px; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.book.add { background: transparent; border: 1px dashed var(--line); box-shadow: none; color: var(--muted); }
.book.add .frame { border: 0; }
.book.add .plus { font-size: 26px; line-height: 1; }
.book.add .name { font-size: 10px; letter-spacing: .08em; }
.shelf-row { border: 1px solid var(--line); border-top: 0; padding: 34px 8px 0; min-height: 190px;
  display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.shelf-row:first-child { border-top: 1px solid var(--line); }
/* Routine */
#routine-bar { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 14px; gap: 10px; }
.pills { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.pills button { padding: 8px 16px; font-size: 13px; letter-spacing: .06em; color: var(--muted); }
.pills button.on { background: var(--ink); color: var(--bg); }
button.small { padding: 10px 16px; font-size: 12px; }
.when-due { font-size: 13px; margin-top: 3px; color: var(--muted); }
.when-due.today { color: var(--ink); font-weight: 700; }
.when-due.late { color: #f0b06a; font-weight: 600; } /* ambre, pas rouge : on informe, on ne culpabilise pas */
.later { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 12px; flex: none; min-height: 36px; }

/* ADHD friendly : grandes zones à toucher, retours visibles, rien d'anxiogène */
.chk { position: relative; width: 30px; height: 30px; }
.chk::after { content: ''; position: absolute; inset: -9px; }  /* zone tactile 48px */
.x { min-width: 44px; min-height: 44px; }
.chk.pop { animation: pop .35s ease; background: var(--ink); color: var(--bg); }
@keyframes pop { 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
li.leaving { opacity: 0; transform: translateX(24px); transition: opacity .3s, transform .3s; }
@media (prefers-reduced-motion: reduce) { .chk.pop, li.leaving { animation: none; transition: none; } }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 50;
  max-width: 488px; margin: auto; background: var(--ink); color: var(--bg); border-radius: 16px; padding: 12px 14px 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
#toast button { color: #5c3708; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 12px;
  padding: 12px; min-height: 44px; }

/* Bloc « Aujourd'hui » : seulement l'essentiel, 3 choses maximum */
#today { margin: 18px 0 0; padding: 16px 16px 8px; border: 1px solid var(--line); background: var(--paper); }
#today h3 { margin: 0 0 6px; font-size: 24px; font-weight: 500; }
#today .none { color: var(--muted); font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 19px; margin: 4px 0 10px; }
#today .row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
#today .row .tt { flex: 1; min-width: 0; font-size: 17px; }
#today .row .tt small { display: block; color: var(--muted); font-size: 13px; }
#today .more { display: block; width: 100%; text-align: left; color: var(--muted); font-size: 13px; letter-spacing: .08em;
  text-transform: uppercase; padding: 12px 0 10px; border-top: 1px solid var(--line); }
.presets { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; margin: 0 -4px; }
.presets button { flex: none; width: auto; margin: 0; display: inline-block; padding: 9px 14px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
li.other { opacity: .62; }
.last { color: var(--muted); font-size: 13px; margin-top: 3px; }
li.clickable .txt { cursor: pointer; }
.every { display: flex; align-items: center; gap: 10px; }
.every input { width: 70px; text-align: center; }
select { font: inherit; padding: 12px 8px; border: 0; border-bottom: 1px solid var(--line); background: transparent;
  color: var(--ink); border-radius: 0; flex: 1; }
input[type=date] { font: inherit; min-height: 48px; }
#rd-for button { font-size: 17px; padding: 12px 4px; }
dialog button.danger { border: 0; color: #f0907f; font-size: 14px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.sw { width: 34px; height: 46px; border-radius: 2px 4px 4px 2px; padding: 0; border: 2px solid transparent; }
.sw.on { border-color: var(--ink); }
#nb-type button { font-size: 16px; padding: 12px 6px; }

/* Page d'une catégorie */
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.back { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 8px 0; }
#title { font-size: 46px; line-height: 1; }
.subtitle { color: var(--muted); margin: 8px 0 20px; font-size: 14px; }
#search { margin-bottom: 4px; }
#add { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin: 4px 0 8px; }
#add input { flex: 1 1 60%; }
#add input#add-detail { flex: 1 1 100%; order: 3; }
#add button { width: 46px; height: 46px; border-radius: 50%; padding: 0; font-size: 22px; flex: none; }

#list { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
#list li { border-bottom: 1px solid var(--line); padding: 14px 2px; display: flex; align-items: center; gap: 14px; }
#list li.done .t { text-decoration: line-through; color: var(--muted); }
#list li.done .emo { opacity: .45; }
.emo { font-size: 26px; width: 34px; text-align: center; flex: none; }
.chk { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--ink); padding: 0; flex: none;
  color: var(--bg); font-size: 12px; line-height: 1; }
li.done .chk { background: var(--ink); }
.txt { flex: 1; min-width: 0; }
.t { font-size: 17px; word-wrap: break-word; }
.d { color: var(--blue); font-size: 14px; margin-top: 2px; }
.m { color: var(--muted); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; margin-top: 3px; }
.when { font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-size: 14px; color: var(--blue); margin-top: 3px; }
.x { color: var(--muted); padding: 6px 4px; font-size: 16px; }
#empty { text-align: center; color: var(--muted); margin-top: 50px; font-family: "Cormorant Garamond", serif; font-size: 22px; font-style: italic; }

dialog { border: 1px solid var(--line); border-radius: 0; background: var(--bg); color: var(--ink); padding: 24px; width: min(92vw, 380px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog button { display: block; width: 100%; margin-top: 12px; padding: 12px; }
dialog button:not(.primary) { border: 1px solid var(--line); border-radius: 999px; }
dialog h2 { font-size: 30px; margin-bottom: 8px; }

/* ---------- Pièces, choix rapides ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px; -webkit-overflow-scrolling: touch; }
.chip { flex: none; display: inline-block; width: auto !important; margin: 0 !important; padding: 9px 14px !important;
  font-size: 14px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; background: transparent; color: var(--ink); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
#add-opts { flex: 1 1 100%; order: 4; }
#add { align-items: flex-start; }
.opt-l { margin: 10px 0 4px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.opt-l span { text-transform: none; letter-spacing: 0; }
#add input#add-place { flex: 1 1 100%; order: 3; }
.room-h { list-style: none; border: 0 !important; padding: 20px 2px 8px !important; font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 24px; font-weight: 500; display: block !important; }
.room-h small { font-family: "Raleway", sans-serif; font-size: 12px; color: var(--muted); letter-spacing: .1em; margin-left: 8px; }
.recipe-use { color: var(--ink); font-size: 15px; margin-top: 4px; }
.recipe-place { color: var(--blue); font-size: 14px; margin-top: 3px; }

/* ---------- Menu du bas ---------- */
#app { padding-bottom: 110px; }
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--bg);
  border-top: 1px solid var(--line); padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); }
#tabbar button { flex: 1; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 6px 0; min-height: 52px; }
#tabbar button span { display: block; font-size: 22px; letter-spacing: 0; }
#tabbar button.on { color: var(--ink); font-weight: 600; }
#toast { bottom: calc(env(safe-area-inset-bottom) + 78px); }

/* ---------- Barre de progression : vide = rouge, pleine = verte ---------- */
.progress { position: relative; height: 48px; border: 1px solid var(--ink); border-radius: 24px; overflow: hidden; margin: 8px 0 14px; }
.progress .fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; transition: width .7s ease, background-color .7s ease; }
.progress .label { position: relative; z-index: 1; height: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; font-size: 15px; font-weight: 600; }
.progress .label small { font-weight: 400; opacity: .8; }

/* ---------- Page Réussites ---------- */
#wins h2 { font-size: 46px; line-height: 1; margin: 18px 0 4px; }
.win-sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.win-card { border: 1px solid var(--line); background: var(--paper); padding: 16px; margin-bottom: 14px; }
.win-card h3 { margin: 0 0 8px; font-family: "Cormorant Garamond", Georgia, serif; font-size: 26px; font-weight: 500; }
.streak { display: flex; align-items: baseline; gap: 10px; }
.streak b { font-family: "Cormorant Garamond", Georgia, serif; font-size: 56px; line-height: 1; font-weight: 500; }
.streak span { color: var(--muted); font-size: 14px; }
.dots { display: flex; gap: 5px; margin: 14px 0 4px; }
.dotcol { flex: 1; text-align: center; font-size: 9px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.dot { display: block; width: 100%; aspect-ratio: 1; max-width: 22px; margin: 0 auto 4px; border-radius: 50%; border: 1.5px solid var(--line); }
.dot.ok { background: #4f8a5b; border-color: #4f8a5b; }
.dot.miss { border-color: #f0b06a; background: repeating-linear-gradient(45deg, transparent 0 3px, rgba(232,160,87,.35) 3px 4px); }
.dot.none { border-style: dashed; opacity: .6; }
.dot.pending { border-color: var(--ink); border-width: 2px; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(242,231,212,.25); } }
@media (prefers-reduced-motion: reduce) { .dot.pending { animation: none; } }
.firstline { margin: 10px 0 0; font-size: 16px; }
.duel-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.duel-row .nm { width: 78px; font-size: 15px; }
.duel-row .bar { flex: 1; height: 16px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.duel-row .bar i { display: block; height: 100%; background: #4f8a5b; transition: width .6s ease; }
.duel-row .n { width: 26px; text-align: right; font-weight: 600; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge { text-align: center; padding: 12px 4px; border: 1px solid var(--line); background: var(--bg); font-size: 11px; line-height: 1.25; }
.badge b { display: block; font-size: 30px; font-weight: 400; margin-bottom: 4px; }
.badge.locked { opacity: .4; filter: grayscale(1); }

/* Choix « pour qui / pièce » : visibles seulement quand on est en train d'écrire (moins de bruit) */
#add:not(:focus-within) #add-opts { display: none; }
#add .chip { height: auto; min-height: 40px; font-size: 14px; border-radius: 999px; padding: 9px 14px !important; }
#add .chip.on { background: var(--ink); color: var(--bg); }
.dot.joker { border-color: #4f8a5b; border-style: dashed; background: rgba(79,138,91,.18); }
.joker-note { margin-top: 0; }

/* ---------- Info du jour ---------- */
#tips h2 { font-size: 46px; line-height: 1; margin: 18px 0 4px; }
.tip-card { padding: 20px 18px; }
.tip-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.tip-cat { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: var(--muted); }
.tip-n { font-size: 12px; color: var(--muted); }
.tip-emoji { font-size: 54px; line-height: 1.1; margin: 10px 0 4px; }
.tip-card .tip-title { font-size: 30px; line-height: 1.1; margin: 0 0 10px; }
.tip-text { font-size: 17px; line-height: 1.5; margin: 0 0 8px; }
.tip-points { margin: 8px 0; padding-left: 20px; font-size: 16px; line-height: 1.5; }
.tip-caution { background: rgba(232,160,87,.14); border-left: 3px solid #f0b06a; padding: 10px 12px; margin: 12px 0 0; font-size: 15px; line-height: 1.45; }
.link-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.link-row .tt { flex: 1; min-width: 0; font-size: 16px; }
.link-row .tt small { display: block; color: var(--muted); font-size: 13px; }
.link-row.recipe { border-top: 0; padding: 6px 0; }
.tip-nav { display: flex; gap: 10px; margin: 6px 0 10px; }
.tip-nav button { flex: 1; border: 1px solid var(--line); border-radius: 999px; padding: 14px; font-size: 15px; min-height: 48px; }
.tip-back { display: block; margin: 0 auto 10px; color: var(--muted); font-size: 14px; padding: 12px; text-decoration: underline; }

/* ---------- Thème sombre (fond marron, plus doux pour les yeux) ---------- */
.book { outline: 1px solid rgba(242,231,212,.14); }
.progress { background: rgba(255,255,255,.04); }
.progress .label { text-shadow: 0 1px 3px rgba(0,0,0,.65); }
.badge.locked { filter: grayscale(1) brightness(.8); }
.dot.joker { background: rgba(79,138,91,.3); }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.85); }

.progress .label .onfill { color: #150d08; text-shadow: none; }

/* ---------- Petites étapes ---------- */
textarea { font: inherit; width: 100%; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); resize: vertical; outline: none; }
textarea::placeholder { color: var(--muted); }
.steps { list-style: none; margin: 8px 0 2px; padding: 0; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 15px; border: 0 !important; }
.steps li.done span { text-decoration: line-through; color: var(--muted); }
.mini { position: relative; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--ink); padding: 0; flex: none; background: none; color: var(--bg); font-size: 12px; }
.mini::after { content: ''; position: absolute; inset: -10px; }
.mini.on { background: var(--ink); }
.mini.on::before { content: '✓'; }
.mini.pop { animation: pop .35s ease; }

/* ---------- « On le fait à deux ? » ---------- */
.tg { flex: none; min-width: 44px; min-height: 44px; font-size: 20px; border: 1px solid var(--line); border-radius: 999px; padding: 0 10px; }
#invites { margin: 18px 0 0; }
.invite { border: 1px solid var(--gold); background: rgba(220,180,79,.12); padding: 14px 16px; margin-bottom: 10px; }
.invite.sent { border-color: var(--line); background: var(--paper); font-size: 15px; padding: 12px 16px; }
.inv-t { font-size: 14px; color: var(--muted); }
.inv-n { font-family: "Cormorant Garamond", Georgia, serif; font-size: 26px; margin: 4px 0 12px; }
.inv-b { display: flex; gap: 10px; align-items: center; }

/* ---------- Réglage du rappel du soir ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 14px 0 4px; font-size: 16px; }
.switch-row small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.switch-row input { width: 24px; height: 24px; accent-color: var(--gold); flex: none; }

.acts { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.acts .tg { min-width: 40px; min-height: 40px; font-size: 18px; }
.acts .later { min-height: 40px; }

.steps-head { display: block; margin-top: 8px; padding: 10px 0; font-size: 14px; color: var(--muted); text-align: left; min-height: 40px; }

/* Carte « équipe » : une seule barre pour vous deux, sans classement */
.team-bar { display: flex; gap: 3px; height: 34px; margin: 12px 0 8px; border: 1px solid var(--line); border-radius: 17px; overflow: hidden; }
.team-bar.empty { opacity: .5; }
.team-bar .seg { display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #150d08; min-width: 0; white-space: nowrap; }
.team-bar .seg.bruna { background: #f6c1d1; }     /* rose pâle */
.team-bar .seg.corentin { background: #a8d0f7; }  /* bleu clair */
