@font-face { font-family: 'Sorts Mill Goudy'; src: url('../fonts/OFLGoudyStMTT.ttf') format('truetype'); font-style: normal; font-display: swap; }
@font-face { font-family: 'Sorts Mill Goudy'; src: url('../fonts/OFLGoudyStMTT-Italic.ttf') format('truetype'); font-style: italic; font-display: swap; }

:root {
  --paper: #f6f5f1; --card: #ffffff; --ink: #1d2733; --muted: #5d6874; --line: #d9d8d0;
  --accent: #2f6b4f; --accent-ink: #ffffff; --rubric: var(--accent);
  /* français : couleur, fond et filet propres, pour le distinguer du latin */
  --fr-bg: #e8eff7; --fr-ink: #213f5e; --fr-line: #4f7cab; --fr-chip: #dbe7f3;
  --exsurge-negative-fill: #ffffff; --rubric-color: var(--accent);
  --fs: 1.2rem; --gut: 2.2rem; --hdr: 7rem;
  --serif: 'Sorts Mill Goudy', 'Iowan Old Style', Georgia, serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14181d; --card: #1b2128; --ink: #e8e6df; --muted: #9aa4af; --line: #2c343d; --exsurge-negative-fill: #1b2128;
    --fr-bg: #1b2735; --fr-ink: #b4cde8; --fr-line: #5f8ab5; --fr-chip: #26384c;
  }
}
:root[data-theme="dark"] {
  --paper: #14181d; --card: #1b2128; --ink: #e8e6df; --muted: #9aa4af; --line: #2c343d; --exsurge-negative-fill: #1b2128;
  --fr-bg: #1b2735; --fr-ink: #b4cde8; --fr-line: #5f8ab5; --fr-chip: #26384c;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--hdr) + .5rem); -webkit-text-size-adjust: 100%; }
body { margin: 0; padding-top: var(--hdr); background: var(--paper); color: var(--ink); font-family: var(--serif); font-size: var(--fs); line-height: 1.55; }
a { color: var(--accent); }
button, select, input { font: inherit; font-family: var(--ui); font-size: .9rem; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- en-tête fixe ---------- */
header.top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; background: var(--paper); border-bottom: 3px solid var(--accent); padding-top: env(safe-area-inset-top, 0px); }
.bar { max-width: 1100px; margin: 0 auto; padding: .4rem .8rem; display: flex; gap: .7rem; align-items: center; }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--ink); text-decoration: none; font-size: 1.5rem; font-style: italic; margin-right: auto; }
.brand img { border-radius: .45rem; display: block; box-shadow: 0 0 0 1px var(--line); }
nav.tabs { display: flex; gap: .2rem; }
nav.tabs a { font-family: var(--ui); font-size: .92rem; text-decoration: none; color: var(--ink); padding: .45rem .75rem; border-radius: .45rem; white-space: nowrap; }
nav.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
nav.tabs .short { display: none; }
.tools { display: flex; gap: .4rem; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: .45rem; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; padding: .4rem .7rem; cursor: pointer; min-height: 2.1rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg.wide { display: flex; width: 100%; max-width: 34rem; }
.seg.wide button { flex: 1; min-height: 2.6rem; font-size: .95rem; }
.btn { border: 1px solid var(--line); background: var(--card); padding: .4rem .8rem; border-radius: .45rem; cursor: pointer; min-height: 2.1rem; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }

/* petit écran : les réglages d'affichage forment une 2e ligne qui se range quand on lit */
@media (max-width: 899px) {
  .tools { position: absolute; left: 0; right: 0; top: 100%; justify-content: center; padding: .35rem .5rem; background: var(--paper); border-bottom: 1px solid var(--line); transition: transform .2s ease; z-index: -1; }
  header.top.tools-hidden .tools { transform: translateY(-120%); }
  .brand span { display: none; }
  .brand { margin-right: 0; }
  nav.tabs { flex: 1; justify-content: space-between; }
  nav.tabs a { padding: .45rem .5rem; flex: 1; text-align: center; }
  nav.tabs .full { display: none; } nav.tabs .short { display: inline; }
  nav.tabs a[data-tab="ordinaire"], nav.tabs a[data-tab="chants"] { font-size: .9rem; }
}
@media (max-width: 420px) { .seg button { padding: .4rem .5rem; } .tools { gap: .25rem; } }

/* ---------- page ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 1rem .9rem 4rem; }
body.has-stepnav main { padding-bottom: 8rem; }
h1 { font-size: 2rem; font-weight: normal; margin: .2rem 0 .2rem; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: normal; margin: 2rem 0 .6rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.15rem; font-weight: normal; font-style: italic; margin: 1.4rem 0 .4rem; color: var(--muted); }
.sub { color: var(--muted); font-family: var(--ui); font-size: .9rem; margin: 0 0 1rem; }
.rubric { color: var(--rubric); }
.note { color: var(--muted); font-style: italic; font-size: .95em; }
.err { font-family: var(--ui); font-size: .9rem; color: #a12d2d; background: color-mix(in srgb, #a12d2d 8%, transparent); padding: .5rem .7rem; border-radius: .4rem; }
.hint { font-family: var(--ui); font-size: .85rem; color: var(--muted); margin: .3rem 0 1rem; }
.controls { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: .8rem 0 1rem; font-family: var(--ui); }
.controls select { padding: .45rem .5rem; border: 1px solid var(--line); border-radius: .45rem; background: var(--card); max-width: 100%; min-height: 2.4rem; }
.controls label { display: inline-flex; gap: .4rem; align-items: center; font-size: .9rem; color: var(--muted); }
.datebar { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: .2rem 0 .8rem; }
.datebar input[type=date] { padding: .35rem .5rem; border: 1px solid var(--line); border-radius: .45rem; background: var(--card); min-height: 2.2rem; }
.dot { display: inline-block; width: .85rem; height: .85rem; border-radius: 50%; background: var(--accent); vertical-align: -.05rem; margin-right: .45rem; }
.panes { margin: .4rem 0 1rem; }
.empty { font-family: var(--ui); color: var(--muted); padding: 1rem; border: 1px dashed var(--line); border-radius: .5rem; }

/* ---------- texte parallèle latin | français ---------- */
.cols-head { display: grid; grid-template-columns: var(--gut) minmax(0, 1fr) minmax(0, 1fr); gap: 0 .9rem; font-family: var(--ui); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; margin: .6rem 0 .2rem; }
.cols-head .c-la { color: var(--muted); font-weight: 600; }
.cols-head .c-fr { color: var(--fr-ink); font-weight: 600; padding-left: .7rem; }
.vrow { display: grid; grid-template-columns: var(--gut) minmax(0, 1fr) minmax(0, 1fr); gap: 0 .9rem; }
.vrow .g { font-family: var(--ui); font-size: .72em; color: var(--rubric); font-weight: 700; padding-top: .5em; text-align: right; padding-right: .3rem; }
.vrow .g.vn { color: var(--muted); font-weight: 400; }
.vrow .la { padding: .3rem 0; font-family: var(--serif); }
.vrow .fr { padding: .3rem .7rem; font-family: var(--ui); font-size: .84em; line-height: 1.5; background: var(--fr-bg); color: var(--fr-ink); border-left: 3px solid var(--fr-line); }
.vrow.resp .la, .vrow.resp .fr { font-weight: bold; }
.vrow.sep { border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.vrow .la:empty::before, .vrow .fr:empty::before { content: '…'; color: var(--muted); }
.note-row { margin: .5rem 0 .2rem; padding-left: calc(var(--gut) + .3rem); font-family: var(--ui); font-size: .82rem; color: var(--muted); font-style: italic; }
.gap { height: .6rem; }

body.layout-stack .vrow, body.layout-stack .cols-head { grid-template-columns: var(--gut) minmax(0, 1fr); }
body.layout-stack .vrow .g { grid-row: 1 / span 2; }
body.layout-stack .vrow .la, body.layout-stack .vrow .fr { grid-column: 2; }
body.layout-stack .vrow .fr { margin: 0 0 .5rem; border-radius: 0 .35rem .35rem 0; }
body.layout-stack .cols-head { display: none; }
body.lang-la .vrow, body.lang-fr .vrow { grid-template-columns: var(--gut) minmax(0, 1fr); }
body.lang-la .vrow .la, body.lang-fr .vrow .fr { grid-column: 2; }
body.lang-la .fr, body.lang-fr .la { display: none; }
body.lang-la .cols-head, body.lang-fr .cols-head { display: none; }
body.lang-fr .vrow .fr { background: transparent; border-left: 0; padding-left: 0; font-family: var(--serif); font-size: 1em; color: var(--ink); }
body.lang-fr .vrow .g.vn, body.lang-la .vrow .g.vn { color: var(--muted); }
@media (max-width: 640px) {
  :root { --gut: 1.7rem; }
  .vrow, .cols-head { gap: 0 .5rem; }
  .vrow .la { font-size: .96em; hyphens: auto; }
  .vrow .fr { padding: .3rem .5rem; font-size: .8em; }
}

.reading { margin: 1.4rem 0 0; }
.reading h3 { margin: 0 0 .1rem; font-style: normal; color: var(--ink); font-size: 1.25rem; }
.reading .ref { font-family: var(--ui); font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.notice { font-family: var(--ui); font-size: .82rem; color: var(--muted); background: color-mix(in srgb, var(--line) 35%, transparent); border-radius: .4rem; padding: .35rem .6rem; margin: .3rem 0; }

/* ---------- chants ---------- */
details.chant { background: var(--card); border: 1px solid var(--line); border-radius: .55rem; margin: .45rem 0; }
details.chant > summary { cursor: pointer; padding: .7rem .9rem; list-style: none; display: flex; gap: .7rem; align-items: baseline; min-height: 3rem; }
details.chant > summary::-webkit-details-marker { display: none; }
details.chant > summary::before { content: '\25B8'; color: var(--accent); }
details.chant[open] > summary::before { content: '\25BE'; }
details.chant .part { font-family: var(--ui); font-size: .78rem; color: var(--accent); font-weight: 700; min-width: 5.2rem; text-transform: uppercase; letter-spacing: .04em; }
details.chant .inc { flex: 1; }
details.chant .score { padding: .2rem .8rem .6rem; color: var(--ink); overflow-x: auto; min-height: 3rem; }
details.chant .score svg { max-width: 100%; height: auto; display: block; }
details.chant .meta { font-family: var(--ui); font-size: .78rem; color: var(--muted); padding: 0 .9rem .7rem; }
details.chant .copts { padding: 0 .9rem .3rem; font-family: var(--ui); }
details.chant .copts select { padding: .3rem .4rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--card); }
.skel { height: 5rem; margin: .4rem 0; border-radius: .4rem; background: linear-gradient(90deg, var(--line) 0, color-mix(in srgb, var(--line) 40%, transparent) 50%, var(--line) 100%); background-size: 200% 100%; animation: sh 1.2s linear infinite; opacity: .55; }
@keyframes sh { to { background-position: -200% 0; } }
.chip-or { font-family: var(--ui); font-size: .72rem; color: var(--muted); text-align: center; margin: .1rem 0; }
.plist-title { font-family: var(--ui); font-size: .8rem; color: var(--muted); margin: 1rem 0 .2rem; }

/* ---------- ordinaire pas à pas ---------- */
.phase { font-family: var(--ui); font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: .2rem 0 0; }
.stephead { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: .4rem; }
.stephead h1 { margin: 0; }
.stephead a { font-family: var(--ui); font-size: .9rem; }
.stepbody { touch-action: pan-y; min-height: 40vh; }
.pick { margin: .6rem 0 .8rem; }
.pick .lbl { font-family: var(--ui); font-size: .78rem; color: var(--muted); margin: 0 0 .25rem; }
.stepnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--paper); border-top: 1px solid var(--line); padding: .5rem .8rem calc(.5rem + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -4px 14px rgba(0, 0, 0, .07); }
.stepnav .progress { position: absolute; left: 0; top: -1px; height: 3px; background: var(--accent); transition: width .2s; }
.stepnav .in { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: center; }
.stepnav button { border: 1px solid var(--line); background: var(--card); border-radius: .6rem; min-height: 3.1rem; padding: .3rem .7rem; cursor: pointer; font-family: var(--ui); display: flex; flex-direction: column; justify-content: center; line-height: 1.2; }
.stepnav button small { color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stepnav .prev { align-items: flex-start; } .stepnav .next { align-items: flex-end; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.stepnav .next small { color: color-mix(in srgb, var(--accent-ink) 80%, transparent); }
.stepnav .next b, .stepnav .prev b { font-size: 1rem; }
.stepnav .mid { align-items: center; min-width: 5.2rem; }
.stepnav button:disabled { opacity: .35; cursor: default; }
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--paper); width: min(34rem, 100%); max-height: 82vh; overflow: auto; border-radius: 1rem 1rem 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 1rem; } }
.sheet h2 { margin: 0 0 .5rem; border: 0; font-size: 1.3rem; display: flex; justify-content: space-between; align-items: center; }
.sheet .ph { font-family: var(--ui); font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: 1rem 0 .25rem; }
.sheet .st { display: flex; width: 100%; text-align: left; gap: .6rem; align-items: center; border: 0; border-radius: .5rem; background: transparent; padding: .6rem .6rem; cursor: pointer; font-family: var(--serif); font-size: 1.1rem; }
.sheet .st .n { font-family: var(--ui); font-size: .75rem; color: var(--muted); min-width: 1.5rem; }
.sheet .st[aria-current="step"] { background: var(--accent); color: var(--accent-ink); }
.sheet .st[aria-current="step"] .n { color: inherit; }

/* ---------- à propos ---------- */
.about p, .about li { max-width: 64ch; font-size: 1rem; }
.about .card { background: var(--card); border: 1px solid var(--line); border-radius: .6rem; padding: .8rem 1rem; margin: .8rem 0; font-family: var(--ui); font-size: .95rem; max-width: 40rem; }
.bar-prog { height: .5rem; background: var(--line); border-radius: .3rem; overflow: hidden; margin: .5rem 0; }
.bar-prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
footer { max-width: 1100px; margin: 0 auto; padding: 1rem .9rem calc(1rem + env(safe-area-inset-bottom, 0px)); color: var(--muted); font-family: var(--ui); font-size: .8rem; border-top: 1px solid var(--line); }
body.has-stepnav footer { display: none; }
@media print { header.top, .controls, footer, .datebar, .stepnav, .panes .seg { display: none; } body { background: #fff; color: #000; padding-top: 0; } }
