:root {
  --bg: #faf6f0;
  --bg-card: #ffffff;
  --ink: #3a332c;
  --ink-soft: #7a6f62;
  --line: #e8e0d4;
  --gold: #b3893f;
  --gold-dark: #8a6a2f;
  --accent: #7a5230;
  --accent-light: #f1e6d7;
  --radius: 18px;
  --shadow: 0 2px 14px rgba(80, 60, 30, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

.screen {
  display: none;
  padding: calc(20px + var(--safe-top)) 20px calc(40px + var(--safe-bottom));
  animation: fadeIn .25s ease;
}
.screen.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- HOME ---------- */
.home-header { text-align: center; margin-bottom: 22px; }
.cross-mark { font-size: 34px; color: var(--gold); margin-bottom: 4px; }
.home-header h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  margin: 0;
  letter-spacing: .5px;
  color: var(--accent);
}
.subtitle { margin: 4px 0 0; color: var(--ink-soft); font-size: 15px; }

.today-card {
  background: linear-gradient(135deg, var(--accent), var(--gold-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 26px;
}
.today-label { font-size: 13px; opacity: .85; text-transform: uppercase; letter-spacing: 1px; }
.today-serie { font-family: Georgia, serif; font-size: 26px; margin: 6px 0 16px; }
.btn-primary {
  background: #fff;
  color: var(--accent);
  border: none;
  border-radius: 30px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:active { transform: scale(.97); }

.section-title {
  font-family: Georgia, serif;
  font-size: 19px;
  color: var(--accent);
  margin: 30px 0 4px;
}
.section-hint { color: var(--ink-soft); font-size: 13px; margin: 0 0 12px; }

.series-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.serie-card {
  border: none;
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: #fff;
}
.serie-card .serie-icon { font-size: 22px; }
.serie-card .serie-nom { font-weight: 700; font-size: 15px; margin-top: 6px; }
.serie-card .serie-jours { font-size: 12px; opacity: .85; margin-top: 2px; }

.mysteres-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.mystere-tile {
  border: none;
  border-radius: 12px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  gap: 2px;
  padding: 4px;
  text-align: center;
}
.mystere-tile .code { font-weight: 800; font-size: 13px; }
.mystere-tile:active { transform: scale(.95); }

.home-footer { margin-top: 34px; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- PLAYER ---------- */
.player-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 17px;
  cursor: pointer;
  color: var(--ink);
}
.player-progress-wrap { text-align: center; }
.player-progress { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.player-next { font-size: 11px; color: var(--ink-soft); opacity: .7; margin-top: 1px; }

.player-hero {
  text-align: center;
  padding: 26px 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  color: #fff;
  background: linear-gradient(160deg, var(--accent), var(--gold-dark));
}
.mystere-badge {
  display: inline-block;
  background: rgba(255,255,255,.22);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.mystere-titre {
  font-family: Georgia, serif;
  font-size: 25px;
  margin: 0 0 6px;
}
.mystere-ref { margin: 0; font-size: 13px; opacity: .85; }
.fruit-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.fruit-chip {
  background: rgba(255,255,255,.18);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
}

#audio-player { display: none; }

.audio-controls { margin-bottom: 18px; }
.seek-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.time { font-size: 11.5px; color: var(--ink-soft); width: 36px; text-align: center; }
#seek-bar { flex: 1; accent-color: var(--accent); }
.transport-row { display: flex; align-items: center; justify-content: center; gap: 26px; }
.btn-transport {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--accent);
  cursor: pointer;
}
.btn-play {
  background: var(--accent);
  color: #fff;
  border: none;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn-play:active, .btn-transport:active { transform: scale(.92); }

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  overflow-x: auto;
}
.tab-btn {
  background: none;
  border: none;
  padding: 10px 4px;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-right: 14px;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

.follow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--accent-light);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.follow-row input { width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto; }

.tab-content { font-size: 15px; line-height: 1.65; color: var(--ink); }
.tab-content p { margin: 0 0 12px; }
.tab-content .label { font-weight: 700; color: var(--accent); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 6px; }
.intentions-list, .clausules-list { margin: 0; padding-left: 0; list-style: none; }
.intentions-list li {
  padding: 8px 0 8px 22px;
  position: relative;
  border-bottom: 1px solid var(--line);
}
.intentions-list li::before { content: "✦"; position: absolute; left: 0; color: var(--gold); font-size: 12px; }
.clausules-list li {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.clausules-list .num {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.evangile-text { font-style: italic; }

/* ---------- MODAL ---------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30, 22, 12, .45);
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 560px;
  border-radius: 22px 22px 0 0;
  padding: 26px 22px calc(30px + var(--safe-bottom));
  position: relative;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
}
.modal-card h3 { font-family: Georgia, serif; color: var(--accent); margin-top: 0; }
.structure-list { padding-left: 20px; line-height: 1.9; }
.modal-note { color: var(--ink-soft); font-size: 13px; margin-top: 16px; }

/* ---------- ENTRÉE "ÉQUIPES DU ROSAIRE" (accueil) ---------- */
.source-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
}
.source-entry-icon { font-size: 20px; color: var(--gold); flex: 0 0 auto; }
.source-entry-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.source-entry-title { font-weight: 700; color: var(--accent); font-size: 15px; }
.source-entry-sub { font-size: 12.5px; color: var(--ink-soft); }
.source-entry-arrow { color: var(--ink-soft); font-size: 16px; }
.source-entry:active { transform: scale(.98); }

/* ---------- ÉCRAN SOURCE : ÉQUIPES DU ROSAIRE ---------- */
.source-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.btn-icon-spacer { width: 40px; height: 40px; }
.source-topbar-title {
  font-family: Georgia, serif;
  color: var(--accent);
  font-size: 20px;
  margin: 0;
}

.credit-card {
  background: linear-gradient(150deg, var(--accent), var(--gold-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 26px;
}
.credit-card p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.6; }
.credit-card p:last-of-type { margin-bottom: 12px; }
.credit-card #source-credit { font-weight: 700; font-size: 14.5px; }
.credit-card a {
  display: inline-block;
  background: rgba(255,255,255,.2);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  border-radius: 20px;
  padding: 7px 14px;
}

.source-block-title {
  font-family: Georgia, serif;
  color: var(--accent);
  font-size: 17px;
  margin: 28px 0 10px;
}

.prayer-block, .prose-block {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-line;
}
.prayer-block { font-style: italic; }
.prayer-auteur { text-align: right; font-size: 12.5px; color: var(--ink-soft); margin: 8px 4px 0; }
.prose-block-hint { font-size: 12.5px; color: var(--ink-soft); margin: 8px 2px 0; line-height: 1.55; }

.explication-list { margin: 14px 0 0; padding: 0; }
.explication-list dt {
  font-weight: 700;
  color: var(--accent);
  font-size: 13.5px;
  margin-top: 12px;
}
.explication-list dd {
  margin: 4px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
}

.prayers-accordion { display: flex; flex-direction: column; gap: 8px; }
.prayer-item {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.prayer-item summary {
  padding: 12px 16px;
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  list-style: none;
}
.prayer-item summary::-webkit-details-marker { display: none; }
.prayer-item summary::after { content: "＋"; float: right; color: var(--ink-soft); }
.prayer-item[open] summary::after { content: "－"; }
.prayer-item-text {
  padding: 0 16px 14px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
}

.chapelet-note {
  background: var(--accent-light);
  border-radius: 14px;
  padding: 12px 16px;
  margin-top: 10px;
}
.chapelet-note p { margin: 0; font-size: 13px; color: var(--ink); line-height: 1.6; }

.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-top: 14px;
}
.calc-card label { display: block; font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.calc-row { display: flex; gap: 10px; }
.calc-row input {
  width: 70px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}
.btn-calc { flex: 1; background: var(--accent); color: #fff; padding: 10px 14px; font-size: 14px; }
.calc-result { margin-top: 14px; }
.calc-result-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-light);
  border-radius: 14px;
  padding: 12px 14px;
}
.calc-result-badge {
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  border-radius: 10px;
  padding: 6px 10px;
}
.calc-result-info { flex: 1; }
.calc-result-titre { font-weight: 700; color: var(--accent); font-size: 14.5px; }
.calc-result-date { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.calc-result-btn {
  display: inline-block;
  margin-top: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- ÉCRAN "ALLER PLUS LOIN" ---------- */
.avance-card-desc { font-size: 13px; opacity: .9; margin: 0 0 16px; line-height: 1.5; }

.credit-note {
  font-style: italic;
  border-left: 2px solid var(--gold);
  padding-left: 10px;
  margin-top: 10px;
}

.fontsize-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--accent-light);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 16px;
}
.fontsize-buttons { display: flex; gap: 6px; }
.btn-fontsize {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 38px;
  height: 34px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
}
.btn-fontsize:active { transform: scale(.94); }
.btn-fontsize:disabled { opacity: .4; cursor: default; }
#btn-font-dec { font-size: 11px; }
#btn-font-inc { font-size: 15px; }

#screen-lecture { --text-scale: 1; }
#screen-lecture .lecture-text,
#screen-lecture #lecture-priere {
  font-size: calc(14.5px * var(--text-scale));
  line-height: calc(1.7 * 1);
}

.lecture-text { white-space: pre-line; }
.lecture-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.lecture-nav-label { font-size: 12.5px; color: var(--ink-soft); }

@media (min-width: 420px) {
  .mysteres-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ---------- TABLETTE (portrait / paysage) ---------- */
@media (min-width: 640px) {
  #app { max-width: 700px; }
  .modal-card { max-width: 700px; }
  .screen { padding-left: 28px; padding-right: 28px; }

  .home-header h1 { font-size: 36px; }
  .cross-mark { font-size: 38px; }

  .series-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .mysteres-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
}

/* ---------- TABLETTE PAYSAGE / DESKTOP ---------- */
@media (min-width: 1000px) {
  #app { max-width: 860px; }
  .modal-card { max-width: 720px; }
  .screen { padding-left: 32px; padding-right: 32px; }

  /* Lecteur : colonne média (portrait, contrôles audio) + colonne contenu */
  #screen-player.active {
    display: grid;
    grid-template-columns: 300px 1fr;
    column-gap: 36px;
    align-items: start;
  }
  .player-topbar { grid-column: 1 / -1; grid-row: 1; }
  .player-hero { grid-column: 1; grid-row: 2; margin-bottom: 0; }
  .audio-controls {
    grid-column: 1;
    grid-row: 3;
    margin-bottom: 0;
    position: sticky;
    top: 24px;
  }
  #tabs { grid-column: 2; grid-row: 2; }
  #follow-row { grid-column: 2; grid-row: 3; }
  #tab-content { grid-column: 2; grid-row: 4; }
}
