/* L'Ascendant — Méditations. Mobile d'abord. */
:root {
  --beige: #e8e1d9;
  --bordeaux: #9b1c31;
  --gold: #c6a96b;
  --noir: #121212;

  --bg: var(--beige);
  --surface: #f3ece1;
  --surface-2: #ddd4c9;
  --text: var(--noir);
  --muted: #5e5249;
  --accent: var(--bordeaux);        /* texte d'accent */
  --accent-soft: rgba(155, 28, 49, .1);
  --button: var(--bordeaux);
  --button-text: #fff;
  --line: rgba(18, 18, 18, .12);
  --shadow: 0 12px 32px -16px rgba(18, 18, 18, .35);

  --font-heading: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 18px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--noir);
    --surface: #1e1b19;
    --surface-2: #2a2623;
    --text: var(--beige);
    --muted: #a89c90;
    --accent: var(--gold);
    --accent-soft: rgba(198, 169, 107, .12);
    --line: rgba(232, 225, 217, .14);
    --shadow: 0 12px 32px -16px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--noir);
  --surface: #1e1b19;
  --surface-2: #2a2623;
  --text: var(--beige);
  --muted: #a89c90;
  --accent: var(--gold);
  --accent-soft: rgba(198, 169, 107, .12);
  --line: rgba(232, 225, 217, .14);
  --shadow: 0 12px 32px -16px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--font-body);
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  -webkit-tap-highlight-color: transparent;
}
body.has-mini { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 88px); }
h1, h2, h3 { font-family: var(--font-heading); font-weight: normal; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.9rem, 7vw, 2.6rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
img { max-width: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.eyebrow { font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); margin: 0 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }

/* --- Barre du haut ------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 18px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--font-heading); font-size: 1.15rem; line-height: 1.1; }
.brand img { border-radius: 50%; background: var(--beige); }
.brand small { display: block; font-size: .62rem; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); font-family: var(--font-body); }
.streak-chip { font-size: .9rem; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }

main { max-width: 680px; margin: 0 auto; padding: 8px 18px 24px; outline: none; }

/* --- Barre d'onglets (au pouce) ------------------------------------------ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .72rem; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar a[aria-current="page"] svg { stroke-width: 2.1; }

@media (min-width: 900px) {
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 520px; bottom: 16px; border: 1px solid var(--line); border-radius: 999px; height: var(--tabbar-h); padding: 0; box-shadow: var(--shadow); }
}

/* --- Boutons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 14px 26px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--button); color: var(--button-text);
  font-size: 1.02rem; font-weight: 600; text-decoration: none;
  transition: transform .12s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.gold { background: var(--gold); color: var(--noir); }
.btn.link { background: none; color: var(--muted); min-height: 44px; font-weight: 500; text-decoration: underline; padding: 8px; }
.stack { display: grid; gap: 10px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; border: 0; background: none; cursor: pointer; border-radius: 999px; color: var(--text); }

/* --- Accueil ------------------------------------------------------------- */
.hero { padding: 18px 0 10px; }
.hero p { color: var(--muted); max-width: 32ch; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; margin: 6px 0 18px; padding: 16px 18px;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent-soft); color: var(--text); text-align: left; cursor: pointer;
}
.banner strong { color: var(--accent); }

.card {
  position: relative; display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 16px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-align: left; cursor: pointer;
  transition: transform .12s ease;
}
.card:active { transform: scale(.985); }
.card .num { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-heading); font-size: 1.1rem; background: var(--surface-2); color: var(--muted); }
.card.unlocked .num { background: var(--button); color: #fff; }
.card .body { flex: 1; min-width: 0; }
.card .title { font-family: var(--font-heading); font-size: 1.12rem; line-height: 1.25; display: block; }
.card .meta { font-size: .85rem; color: var(--muted); }
.card .state { flex: none; color: var(--muted); display: grid; place-items: center; }
.card.unlocked .state { color: var(--accent); }
.card.locked .title { color: color-mix(in srgb, var(--text) 75%, transparent); }

.featured { padding: 22px 18px; border-color: var(--gold); background: linear-gradient(160deg, var(--surface), var(--accent-soft)); }
.featured .num { width: 58px; height: 58px; }
.badge { display: inline-block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; background: var(--gold); color: var(--noir); margin-bottom: 4px; }

.pack {
  margin: 22px 0; padding: 22px 20px; border-radius: var(--radius);
  background: var(--noir); color: var(--beige); position: relative; overflow: hidden;
}
:root[data-theme="dark"] .pack { background: var(--surface-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pack { background: var(--surface-2); } }
.pack h3 { color: var(--gold); }
.pack .price { font-family: var(--font-heading); font-size: 2rem; margin: 4px 0 12px; }
.pack .price s { font-size: 1.1rem; opacity: .55; margin-left: 8px; }
.section-title { margin: 26px 0 10px; font-size: .78rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); font-family: var(--font-body); }

/* --- Feuilles modales ---------------------------------------------------------- */
dialog.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh;
  margin: auto auto 0; padding: 0;
  border: 0; border-radius: 24px 24px 0 0;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto; overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgba(10, 8, 7, .55); backdrop-filter: blur(3px); }
dialog.sheet[open] { animation: rise .28s cubic-bezier(.2, .8, .2, 1); }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 24px; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
#modal-body { padding: 26px 22px calc(22px + var(--safe-b)); }
.sheet-handle { width: 42px; height: 5px; border-radius: 99px; background: var(--line); margin: -12px auto 16px; }
.sheet .close { position: absolute; top: 8px; right: 8px; }

.detail dt { font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin-top: 18px; }
.detail dd { margin: 4px 0 0; }
.mantra { font-family: var(--font-heading); font-style: italic; font-size: 1.2rem; color: var(--accent); }

.option {
  display: block; width: 100%; padding: 18px; margin-bottom: 10px; text-align: left; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text);
}
.option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.option .row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.option strong { font-family: var(--font-heading); font-size: 1.1rem; font-weight: normal; }
.option .amount { font-weight: 700; white-space: nowrap; }

/* --- Formulaires ---------------------------------------------------------------- */
label { display: block; font-weight: 600; margin: 16px 0 6px; }
input[type="email"], input[type="password"], input[type="text"], input[type="number"], input[type="time"], textarea, select {
  width: 100%; padding: 14px 16px; min-height: 52px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--bg); color: var(--text); font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; margin: 14px 0; cursor: pointer; }
.check input { width: 24px; height: 24px; flex: none; margin: 1px 0 0; accent-color: var(--bordeaux); }
.error { color: #c2334b; font-weight: 600; margin: 10px 0 0; }
:root[data-theme="dark"] .error { color: #ff8a9c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .error { color: #ff8a9c; } }
.linkbox { word-break: break-all; font-size: .8rem; padding: 10px; border-radius: 10px; background: var(--bg); color: var(--muted); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); font-weight: 400; margin: 0; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 32px; border-radius: 99px; background: var(--surface-2); position: relative; cursor: pointer; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked { background: var(--bordeaux); }
.switch input:checked::after { transform: translateX(20px); }

.segmented { display: grid; grid-auto-flow: column; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.segmented button { min-height: 44px; border: 0; border-radius: 999px; background: none; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.15); font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 18px; margin-bottom: 18px; }
.panel .row { padding: 16px 0; border-bottom: 1px solid var(--line); }
.panel .row:last-child, .panel .switch:last-child { border-bottom: 0; }

/* --- Lecteur ------------------------------------------------------------------ */
.player {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  padding: calc(12px + var(--safe-t)) 22px calc(28px + var(--safe-b));
  background: radial-gradient(120% 70% at 50% 0%, var(--accent-soft), transparent 70%), var(--bg);
  animation: rise .3s cubic-bezier(.2, .8, .2, 1);
}
.player-close { align-self: flex-start; }
.player-close svg { width: 30px; height: 30px; }
.player-head { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; max-width: 520px; margin: 0 auto; }
.player-head h2 { font-size: clamp(1.7rem, 7vw, 2.3rem); }
.player-controls { width: 100%; max-width: 520px; margin: 0 auto; }
.scrub input { width: 100%; height: 36px; accent-color: var(--bordeaux); }
.times { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.buttons { display: flex; align-items: center; justify-content: space-around; margin-top: 18px; }
.big-skip { position: relative; width: 72px; height: 72px; }
.big-skip svg { width: 40px; height: 40px; }
.big-skip span { position: absolute; font-size: .7rem; font-weight: 700; }
.play { width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer; background: var(--button); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow); }
.play svg { width: 40px; height: 40px; fill: currentColor; stroke: none; }
.play:active { transform: scale(.96); }
.i-pause { display: none; }
.is-playing .i-play { display: none; }
.is-playing .i-pause { display: block; }

.mini-player {
  position: fixed; z-index: 21; left: 12px; right: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px);
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 18px;
  border-radius: 999px; background: var(--noir); color: var(--beige); box-shadow: var(--shadow);
  max-width: 560px; margin: 0 auto;
}
.mini-player .icon-btn { color: var(--beige); }
.mini-player svg { fill: currentColor; stroke: none; }
.mini-title { flex: 1; text-align: left; border: 0; background: none; color: inherit; font-family: var(--font-heading); min-height: 48px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (min-width: 900px) { .mini-player { bottom: calc(var(--tabbar-h) + 28px); } }

/* --- Calendrier ------------------------------------------------------------------ */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }
.cal-head h2 { margin: 0; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.cal .dow { font-size: .72rem; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.cal .day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px; background: var(--surface); font-size: .9rem; position: relative; }
.cal .day.empty { background: none; }
.cal .day.today { outline: 1.5px solid var(--accent); }
.cal .day.done { background: var(--accent-soft); color: var(--accent); }
.cal .day.done::after { content: "★"; position: absolute; bottom: 2px; font-size: .8rem; color: var(--gold); }
.streak-big { text-align: center; padding: 22px; margin: 18px 0; border-radius: var(--radius); background: var(--surface); }
.streak-big strong { display: block; font-family: var(--font-heading); font-size: 3rem; line-height: 1; color: var(--accent); }

/* --- Journal ---------------------------------------------------------------------- */
.entry { padding: 16px 18px; margin-bottom: 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.entry .date { font-size: .8rem; color: var(--muted); }
.entry .q { font-size: .88rem; color: var(--accent); margin: 12px 0 2px; }
.entry .a { white-space: pre-wrap; margin: 0; }
.group-title { margin: 24px 0 10px; }
.empty-state { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty-state img { width: 80px; opacity: .7; }

/* --- Célébration, toast ------------------------------------------------------------ */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; pointer-events: none; }
.celebrate { text-align: center; }
.celebrate .count { font-family: var(--font-heading); font-size: 5rem; line-height: 1; color: var(--accent); margin: 10px 0; }
.toast {
  position: fixed; z-index: 90; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  width: max-content; max-width: calc(100% - 32px); text-align: center; padding: 12px 20px; border-radius: 22px;
  background: var(--noir); color: var(--beige); box-shadow: var(--shadow); font-size: .95rem;
}

.prose { max-width: 65ch; }
.prose h2 { margin-top: 1.6em; }
.spinner { width: 34px; height: 34px; margin: 30px auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
