:root {
  --bg: #f5efe4;
  --paper: #fbf8f2;
  --ink: #2b2118;
  --muted: #7a6a58;
  --line: #e2d7c4;
  --accent: #8c2f2b;      /* rouge Passion */
  --accent-soft: #f1dcd6;
  --gold: #b08a3e;
  --ok: #5c7a4a;
  --fs: 1.1;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sys-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sans: var(--sys-sans);
}
/* Apparence : auto (suit le téléphone), claire ou sombre */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1612; --paper: #261e18; --ink: #efe6d8; --muted: #a8977f;
    --line: #3a2f26; --accent: #d0675f; --accent-soft: #3b2420; --gold: #d1ad62; --ok: #8fb07a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1612; --paper: #261e18; --ink: #efe6d8; --muted: #a8977f;
  --line: #3a2f26; --accent: #d0675f; --accent-soft: #3b2420; --gold: #d1ad62; --ok: #8fb07a;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* Polices (fichiers inclus dans l'appli, fonctionnent hors ligne) */
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 400; font-display: swap; src: url(fonts/source-sans-3-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 700; font-display: swap; src: url(fonts/source-sans-3-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "OpenDyslexic"; font-weight: 400; font-display: swap; src: url(fonts/opendyslexic-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "OpenDyslexic"; font-weight: 700; font-display: swap; src: url(fonts/opendyslexic-latin-700-normal.woff2) format("woff2"); }

:root[data-font="lisible"]  { --serif: "Atkinson Hyperlegible", var(--sys-sans); --sans: "Atkinson Hyperlegible", var(--sys-sans); }
:root[data-font="claire"]   { --serif: "Source Sans 3", var(--sys-sans); --sans: "Source Sans 3", var(--sys-sans); }
:root[data-font="dyslexie"] { --serif: "OpenDyslexic", var(--sys-sans); --sans: "OpenDyslexic", var(--sys-sans); }
:root[data-font="dyslexie"] .prayer p, :root[data-font="dyslexie"] .prose p { text-align: left; line-height: 1.8; }
:root[data-font="dyslexie"] .prayer, :root[data-font="dyslexie"] .prose { font-size: calc(.92rem * var(--fs)); }
:root[data-font="claire"] .prayer p, :root[data-font="lisible"] .prayer p { text-align: left; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; min-height: 100vh; }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1, h2, .brand, .big, .prose, .prayer, .lede { font-family: var(--serif); }

.hero { text-align: center; padding: 40px 8px 24px; }
.cross { font-size: 2.2rem; color: var(--accent); }
.hero h1 { font-weight: 400; font-size: 2rem; line-height: 1.2; margin: 12px 0; }
.hero h1 em { color: var(--accent); }
.lede { color: var(--muted); font-size: 1.1rem; line-height: 1.5; margin: 0 auto; max-width: 30ch; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; margin: 16px 0; display: flex; flex-direction: column; gap: 10px;
}
label { font-size: .85rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
input[type=date], input[type=time] {
  font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: 100%;
}
.hint { color: var(--muted); font-size: .9rem; margin: 4px 0; line-height: 1.4; }
.center { text-align: center; }

.btn {
  font: inherit; font-size: 1rem; font-weight: 600; border: 0; border-radius: 12px;
  padding: 14px 18px; cursor: pointer; width: 100%; transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.link { background: none; color: var(--accent); font-weight: 500; }
.btn.danger { background: none; color: var(--accent); border: 1px solid var(--line); margin-top: 8px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px; }
.brand { font-size: 1.1rem; color: var(--accent); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--paper);
  color: var(--ink); font-size: 1.2rem; cursor: pointer; display: grid; place-items: center;
}
.icon-btn.ghost { background: none; }

.ring-wrap { position: relative; width: 220px; height: 220px; margin: 12px auto 4px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.big { font-size: 3.4rem; line-height: 1; }
.small { color: var(--muted); font-size: .9rem; margin-top: 6px; }
.status { text-align: center; color: var(--muted); font-family: var(--serif); font-size: 1.05rem; margin: 8px 0; }

.today-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.today-title { font-family: var(--serif); font-size: 1.2rem; }
.today-sub { color: var(--muted); font-size: .9rem; }
.badge { font-size: .8rem; font-weight: 700; padding: 6px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.tile span { color: var(--gold); font-size: 1.3rem; }

.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }

.prayer, .prose { font-size: calc(1rem * var(--fs)); line-height: 1.65; }
.prayer { padding: 8px 4px 120px; }
.prayer h2 { font-weight: 400; color: var(--accent); font-size: 1.5em; text-align: center; margin: 18px 0; }
.prayer p { margin: 0 0 1em; text-align: justify; hyphens: auto; }
.pater { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: .9em; }
.pater summary { cursor: pointer; color: var(--muted); font-family: var(--sans); font-size: .85rem; font-weight: 600; }
.pater p { margin-top: 10px; }

.pray-nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%); max-width: 560px; margin: 0 auto;
}

.prose h2 { font-weight: 400; color: var(--accent); font-size: 1.35em; margin: 1.2em 0 .5em; }
.prose p { margin: 0 0 1em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .5em; }
.prose a { color: var(--accent); text-underline-offset: 3px; }
.prose .note { font-size: .9em; color: var(--muted); border-left: 3px solid var(--gold); padding-left: 12px; }
.prose .btn { margin-top: 12px; }

.legend { display: flex; justify-content: center; gap: 14px; font-size: .8rem; color: var(--muted); margin-bottom: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.dot.done, .cell.done { background: var(--accent); }
.dot.missed, .cell.missed { background: var(--line); }
.dot.today { outline: 2px solid var(--gold); background: transparent; }
.grid { display: flex; flex-direction: column; gap: 14px; }
.month h3 { font-family: var(--serif); font-weight: 400; font-size: 1rem; margin: 0 0 6px; color: var(--muted); text-transform: capitalize; }
.month-cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cell {
  aspect-ratio: 1; border-radius: 6px; border: 0; padding: 0; font: inherit; font-size: .7rem;
  color: var(--muted); background: transparent; cursor: default;
}
.cell.done { color: #fff; }
.cell.missed, .cell.done { cursor: pointer; }
.cell.future { background: var(--paper); border: 1px solid var(--line); }
.cell.today { outline: 2px solid var(--gold); outline-offset: -2px; }
.cell.pad { visibility: hidden; }

.switch-row { display: flex; justify-content: space-between; align-items: center; color: var(--ink); font-size: 1rem; font-weight: 500; margin-top: 6px; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button {
  font-family: var(--serif); background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 0; cursor: pointer;
}
#font-seg button:nth-child(1) { font-size: .9rem; } #font-seg button:nth-child(2) { font-size: 1.1rem; }
#font-seg button:nth-child(3) { font-size: 1.35rem; } #font-seg button:nth-child(4) { font-size: 1.6rem; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg.three button { font-family: var(--sans); font-size: .95rem; font-weight: 600; padding: 12px 0; }
.seg.fonts { grid-template-columns: 1fr 1fr; }
.seg.fonts button { font-size: .9rem; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.seg.fonts b { font-size: 1.5rem; font-weight: 400; line-height: 1.2; }
.seg .f-classique { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif !important; }
.seg .f-lisible { font-family: "Atkinson Hyperlegible", sans-serif !important; }
.seg .f-claire { font-family: "Source Sans 3", sans-serif !important; }
.seg .f-dyslexie { font-family: "OpenDyslexic", sans-serif !important; font-size: .8rem !important; }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
