:root {
  --bg: #0e0c0a;
  --surface: #15110d;
  --surface-2: #211a14;
  --text: #f3ede2;
  --text-muted: #a2968a;
  --accent: #e2a95d;
  --accent-deep: #c9822e;
  --border: rgba(255, 225, 180, 0.10);
  --glass-bg: rgba(24, 19, 15, 0.62);
  --radius: 16px;
  --app-w: 480px;
  --sidebar-w: 264px;
  --tier-0: #1a1511;
  --tier-1: #38291a;
  --tier-2: #6b4620;
  --tier-3: #a86e2a;
  --tier-4: #e2a95d;
  --grad: linear-gradient(135deg, #ecb96e 0%, #c9822e 100%);
  --tabbar-h: 60px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { overflow-x: hidden; }
.svg-sprite { position: absolute; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

input, select, textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
}
textarea { resize: none; }

/* ---- Icônes ---- */
.ic {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  display: inline-block; vertical-align: middle; flex: 0 0 auto;
}
.ic-lg { width: 40px; height: 40px; }
.ic-amber { color: var(--accent); }

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--border);
}

.muted { color: var(--text-muted); }
.mobile-only { display: revert; }
.desktop-only { display: none; }

/* ============================================================
   BOUTONS
   ============================================================ */
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%;
  background: var(--grad);
  color: #231507;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  box-shadow: 0 8px 28px rgba(226, 169, 93, 0.22);
  transition: opacity .2s, transform .12s;
}
.primary-btn .ic { width: 19px; height: 19px; stroke-width: 2; }
.primary-btn:active { opacity: .9; transform: scale(.99); }
.primary-btn:disabled { opacity: .5; }

.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: border-color .2s;
}
.ghost-btn .ic { width: 18px; height: 18px; }
.ghost-btn.danger { color: #d0876a; border-color: rgba(208,135,106,.28); }

.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--accent); font-size: 14px; padding: 8px 2px;
}
.link-btn .ic { width: 18px; height: 18px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px;
  color: var(--text-muted);
  transition: color .2s, background .2s;
}
.icon-btn:hover { color: var(--text); }
.icon-btn:active { background: var(--surface-2); }

/* ---- Switch ---- */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); transition: background .2s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #8a7d70; transition: transform .22s, background .2s; }
.switch input:checked + .switch-track { background: var(--grad); border-color: transparent; }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: #231507; }

/* ============================================================
   BASE MOBILE — chaque vue est plein écran dans #main
   ============================================================ */
#main { width: 100%; }
.view {
  min-height: 100vh; min-height: 100dvh;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
  position: relative;
  background: var(--bg);
  max-width: var(--app-w);
  margin: 0 auto;
}
.screen-h1 { font-size: 22px; font-weight: 400; margin: 4px 0 18px; }
.view-title { font-size: 24px; font-weight: 400; margin: 0 0 20px; }
.hint { font-size: 13.5px; line-height: 1.5; color: var(--text-muted); margin: 0 0 14px; }

.auto-card { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 15px 16px; border-radius: 18px; border: 1px solid rgba(226,169,93,.32); background: linear-gradient(120deg, rgba(226,169,93,.14), rgba(226,169,93,.04)); margin-bottom: 18px; transition: transform .12s, border-color .2s; }
.auto-card:active { transform: scale(.99); }
.auto-icon { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: rgba(226,169,93,.18); color: var(--accent); }
.auto-icon .ic { width: 22px; height: 22px; }
.auto-text { display: flex; flex-direction: column; gap: 3px; }
.auto-title { font-size: 15px; font-weight: 600; color: var(--text); }
.auto-sub { font-size: 12.5px; line-height: 1.4; color: var(--text-muted); }
.field-label { font-size: 13px; color: var(--text-muted); }

/* Overlays plein écran (login, génération, player) */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--bg); }

.fullbleed-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.fullbleed-scrim { position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(14,12,10,.30) 0%, rgba(14,12,10,.55) 60%, rgba(14,12,10,.86) 100%); }
.error { color: #d08770; font-size: 14px; margin: 0; }

/* ---- Topbar (mobile) ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; min-height: 40px; }
.topbar h1 { font-size: 19px; font-weight: 400; letter-spacing: .1em; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.streak-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 600; padding: 6px 12px 6px 10px; border-radius: 999px; background: var(--grad); color: #231507; }
.streak-badge .ic { width: 16px; height: 16px; stroke-width: 2; }
.streak-badge.at-stake { background: rgba(24,19,15,.5); color: var(--accent); border: 1px solid var(--border); }

/* ============================================================
   LOGIN
   ============================================================ */
#screen-login { display: flex; align-items: center; justify-content: center; }
#login-form {
  position: relative; z-index: 2; width: min(88vw, 340px);
  display: flex; flex-direction: column; gap: 13px; text-align: center;
  border-radius: 24px; padding: 30px 24px;
}
.login-logo { width: 56px; height: 56px; border-radius: 15px; margin: 0 auto 4px; }
#login-form h1 { font-weight: 400; font-size: 25px; letter-spacing: .12em; margin: 0 0 8px; }
#login-form input { background: rgba(14,12,10,.5); text-align: center; }

/* ============================================================
   ACCUEIL / CALENDRIER
   ============================================================ */
#screen-home { overflow: hidden; }
.home-glow { position: absolute; top: -180px; left: 50%; transform: translateX(-50%); width: 560px; height: 420px; background: radial-gradient(ellipse at center, rgba(226,169,93,.12) 0%, transparent 65%); pointer-events: none; z-index: 0; }
.home-layout { position: relative; z-index: 1; }
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#month-label { font-size: 15px; text-transform: capitalize; }
.weekday-row { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-cell {
  aspect-ratio: 1; border-radius: 12px;
  background: var(--tier-0); color: var(--text-muted);
  font-size: 13px; display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .2s;
}
.day-cell:active { transform: scale(.92); }
.day-cell.empty { background: transparent; }
.day-cell.tier-1 { background: var(--tier-1); color: var(--text); }
.day-cell.tier-2 { background: var(--tier-2); color: var(--text); }
.day-cell.tier-3 { background: var(--tier-3); color: #1c120a; font-weight: 600; }
.day-cell.tier-4 { background: var(--tier-4); color: #231507; font-weight: 600; box-shadow: 0 0 18px rgba(226,169,93,.25); }
.day-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.day-cell.selected { box-shadow: inset 0 0 0 2px var(--text); }

.fab {
  position: fixed; z-index: 20;
  right: max(20px, calc((100vw - var(--app-w)) / 2 + 20px));
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--grad); color: #231507;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 32px rgba(226,169,93,.35);
  transition: transform .15s;
}
.fab .ic { width: 26px; height: 26px; stroke-width: 2.2; }
.fab:active { transform: scale(.92); }

/* Contenu jour (partagé sheet mobile / panneau desktop) */
.day-head { font-size: 17px; font-weight: 500; text-transform: capitalize; margin: 2px 0 14px; }
.day-empty { color: var(--text-muted); font-size: 14px; padding: 6px 0 14px; }
.session-row {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center;
  width: 100%; padding: 12px 8px; border-bottom: 1px solid var(--border); text-align: left;
  border-radius: 10px; transition: background .15s;
}
.session-row:hover { background: rgba(255,225,180,.03); }
.session-row:last-of-type { border-bottom: none; }
.session-time { color: var(--text-muted); font-size: 13px; }
.session-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.session-type { color: var(--accent); font-size: 12px; }
.session-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-duration { color: var(--text-muted); font-size: 13px; }
.add-toggle { margin-top: 6px; }
.add-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.add-form select, .add-form input { width: 100%; }

/* ============================================================
   NOUVELLE MÉDITATION
   ============================================================ */
.mode-toggle { display: flex; gap: 4px; margin-bottom: 18px; border-radius: var(--radius); padding: 4px; background: var(--glass-bg); border: 1px solid var(--border); }
.mode-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px; border-radius: 11px; color: var(--text-muted); font-size: 14px; transition: background .2s, color .2s; }
.mode-btn .ic { width: 17px; height: 17px; }
.mode-btn.active { background: var(--grad); color: #231507; font-weight: 600; }
#guide-feeling { width: 100%; margin-bottom: 18px; }
.duration-block { margin-bottom: 20px; }
.duration-block .field-label { display: block; margin-bottom: 8px; }
.duration-row { display: flex; gap: 8px; flex-wrap: wrap; }
.duration-row button { flex: 1; min-width: 44px; padding: 11px 0; border-radius: 12px; background: var(--glass-bg); border: 1px solid var(--border); font-size: 14px; color: var(--text-muted); transition: background .2s, color .2s; }
.duration-row button.active { background: var(--grad); border-color: transparent; color: #231507; font-weight: 600; }

.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-card {
  position: relative; aspect-ratio: 4 / 5; border-radius: 18px; overflow: hidden;
  text-align: left; border: 1px solid var(--border); padding: 0; background: var(--surface-2);
  transition: transform .15s, box-shadow .2s, border-color .2s;
}
.type-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.type-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14,12,10,0) 28%, rgba(14,12,10,.55) 62%, rgba(14,12,10,.93) 100%); }
.type-card:hover img { transform: scale(1.04); }
.type-card-text { position: absolute; left: 12px; right: 12px; bottom: 11px; z-index: 1; display: flex; flex-direction: column; gap: 3px; }
.type-card-label { font-size: 15px; font-weight: 600; }
.type-card-desc { font-size: 11.5px; line-height: 1.35; color: rgba(243,237,226,.78); }
.type-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 8px 30px rgba(226,169,93,.25); }
.type-card.active .type-card-label { color: var(--accent); }

/* Détail d'un type */
#type-detail-content { display: flex; flex-direction: column; }
.td-hero { position: relative; height: 150px; border-radius: 18px; overflow: hidden; margin-bottom: 16px; }
.td-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.td-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14,12,10,.1), rgba(14,12,10,.75)); }
.td-hero .td-name { position: absolute; left: 16px; bottom: 12px; z-index: 1; font-size: 21px; font-weight: 500; }
.td-back { margin-bottom: 8px; }
.td-tagline { color: var(--accent); font-size: 13px; margin: 0 0 16px; }
.td-block { margin-bottom: 16px; }
.td-block h4 { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 6px; }
.td-block p { font-size: 14.5px; line-height: 1.6; margin: 0; }
.td-examples { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.td-examples li { display: flex; gap: 9px; font-size: 14px; line-height: 1.45; align-items: flex-start; }
.td-examples .ic { width: 15px; height: 15px; color: var(--accent); margin-top: 3px; }
.td-actions { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.td-sub { width: 100%; margin: 0 0 16px; }
.td-actions .field-label { display: block; margin-bottom: 10px; }
.td-actions .duration-row { margin-bottom: 18px; }

/* ============================================================
   GÉNÉRATION
   ============================================================ */
#screen-generating { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; }
.breathing-orb { width: 150px; height: 150px; border-radius: 50%; object-fit: cover; animation: breathe 4.5s ease-in-out infinite; box-shadow: 0 0 70px rgba(226,169,93,.35); }
.generating-text { color: var(--text-muted); font-size: 14px; letter-spacing: .02em; }
@keyframes breathe { 0%,100% { transform: scale(.86); box-shadow: 0 0 40px rgba(226,169,93,.2); } 50% { transform: scale(1.12); box-shadow: 0 0 90px rgba(226,169,93,.45); } }

/* ============================================================
   APERÇU
   ============================================================ */
.has-hero { padding-top: 0; }
.hero { position: absolute; top: 0; left: 0; right: 0; height: 42vh; z-index: 0; overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero-scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14,12,10,.25) 0%, rgba(14,12,10,.35) 55%, var(--bg) 100%); }
.over-hero { position: relative; z-index: 2; padding-top: calc(16px + env(safe-area-inset-top)); }
.hero-spacer { height: calc(30vh - 60px); }
.preview-body { position: relative; z-index: 1; }
.preview-eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.preview-type { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); }
.fallback-badge { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; background: var(--glass-bg); }
#preview-title { font-size: 26px; font-weight: 400; margin: 0 0 10px; }
.detail-why { color: var(--text); font-size: 14.5px; line-height: 1.55; margin: 0 0 18px; }
.outline-card { border-radius: 18px; padding: 4px 16px; margin-bottom: 24px; }
.outline-row { display: flex; justify-content: space-between; padding: 13px 2px; border-bottom: 1px solid var(--border); font-size: 14px; }
.outline-row:last-child { border-bottom: none; }
.outline-minutes { color: var(--text-muted); }

/* ============================================================
   PLAYER
   ============================================================ */
#screen-player { display: flex; flex-direction: column; justify-content: flex-end; }
.player-scrim { position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(14,12,10,.12) 0%, rgba(14,12,10,.35) 42%, rgba(14,12,10,.88) 76%, var(--bg) 100%); }
.player-close { position: absolute; top: calc(16px + env(safe-area-inset-top)); left: 16px; z-index: 3; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text); }
.player-inner { position: relative; z-index: 2; width: 100%; max-width: 620px; margin: 0 auto; padding: 22px 22px calc(30px + env(safe-area-inset-bottom)); }
#player-step-label { color: var(--accent); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 14px; }
#player-step-text { font-size: 20px; line-height: 1.75; font-weight: 300; white-space: pre-line; margin: 0 0 26px; max-height: 44vh; overflow-y: auto; -webkit-mask-image: linear-gradient(180deg, #000 88%, transparent 100%); mask-image: linear-gradient(180deg, #000 88%, transparent 100%); }
.chapter-dots { display: flex; justify-content: center; gap: 7px; margin-bottom: 14px; }
.cdot { width: 22px; height: 5px; border-radius: 3px; background: rgba(255,225,180,.16); transition: background .2s; padding: 0; }
.cdot.active { background: rgba(226,169,93,.55); }
.cdot.current { background: var(--accent); }
.step-progress { height: 3px; background: rgba(255,225,180,.14); border-radius: 2px; overflow: hidden; margin-bottom: 16px; }
.step-progress-fill { height: 100%; width: 0%; background: var(--grad); }
.player-buttons { display: flex; align-items: center; justify-content: center; gap: 18px; }
.pnav { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; color: var(--text); border: 1px solid var(--border); background: var(--glass-bg); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); transition: transform .12s, border-color .2s; }
.pnav .ic { width: 22px; height: 22px; }
.pnav:active { transform: scale(.9); }
.pause-btn { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-size: 14px; padding: 10px 22px; border-radius: 999px; border: 1px solid var(--border); background: var(--glass-bg); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.pause-btn .ic { width: 16px; height: 16px; }
#player-finished { text-align: center; }
.done-check { margin-bottom: 12px; }
#player-closing-text { font-size: 19px; font-weight: 300; line-height: 1.65; margin: 0 0 24px; }
#player-ideas { width: 100%; margin-bottom: 16px; }

/* ============================================================
   RÉGLAGES
   ============================================================ */
.settings-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--glass-bg); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); padding: 4px 16px; margin-bottom: 6px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-label { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; }
.settings-label .ic { width: 18px; height: 18px; color: var(--text-muted); }
.settings-row input[type="time"] { width: auto; padding: 8px 10px; }
.settings-row select { max-width: 58%; }
.settings-hint { font-size: 12px; line-height: 1.5; color: var(--text-muted); margin: 12px 4px 0; }
.settings-btn { margin-top: 16px; }
.settings-status { text-align: center; font-size: 13px; color: var(--text-muted); margin: 12px 0 0; min-height: 1em; }
.logout-btn { justify-content: center; color: var(--text-muted); margin-top: 34px; width: 100%; }

/* ============================================================
   SHEETS / MODALES
   ============================================================ */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(8,6,4,.6); z-index: 45; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: var(--app-w); margin: 0 auto; z-index: 46;
  border-radius: 22px 22px 0 0; border-bottom: none;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 84vh; overflow-y: auto;
  animation: sheet-in .24s ease-out;
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 6px auto 14px; }
#modal-detail h2 { font-size: 18px; font-weight: 500; margin: 6px 0 10px; text-transform: capitalize; }
.detail-meta { display: flex; flex-direction: column; gap: 2px; color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
.detail-step { margin-bottom: 18px; }
.detail-step h3 { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); margin: 0 0 6px; }
.detail-step p { font-size: 14px; line-height: 1.65; margin: 0; white-space: pre-line; }
#detail-note { font-size: 14px; line-height: 1.5; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 14px; margin-bottom: 16px; white-space: pre-line; }
#detail-delete { margin-top: 6px; }

/* ============================================================
   AFFIRMATIONS
   Même design system que le reste : on ne redéfinit ici que ce qui n'existe pas
   ailleurs. Le lecteur d'affirmations est scopé sous #screen-aff-player pour ne
   jamais marcher sur celui de la méditation.
   ============================================================ */
.screen-title { font-size: 22px; font-weight: 400; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.section-h2 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 26px 0 10px; }
.count-line { font-size: 13px; margin: 4px 0 12px; }
/* .empty-state, pas .empty : les cases vides du calendrier portent déjà `day-cell empty`,
   et leur donner du padding faisait déborder la grille du mois. */
.empty-state { color: var(--text-muted); font-size: 14px; text-align: center; padding: 34px 20px; line-height: 1.6; }

/* Bascule FR / EN */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.seg button { padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--text-muted); transition: color .2s, background .2s; }
.seg button.on { background: var(--grad); color: #231507; }

.icon-btn.accent { color: #231507; background: var(--grad); width: 40px; height: 40px; }
.icon-btn.small { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.small .ic { width: 18px; height: 18px; }

.add-row { display: flex; gap: 8px; align-items: center; }
.add-row input { width: 100%; }
.title-input { width: 100%; font-size: 19px; font-weight: 600; margin-bottom: 4px; }

.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.card { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 12px 12px 14px; }
.card-text { flex: 1; font-size: 15px; line-height: 1.45; min-width: 0; overflow-wrap: anywhere; }
.card-text input[type="text"] { font-size: 15px; }
.card-sub { display: block; color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.card-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.card.chosen { border-color: rgba(226,169,93,.35); }
.card.untranslated { border-left: 2px solid rgba(208,135,106,.55); }
.card-order { color: var(--text-muted); font-size: 12px; width: 20px; text-align: right; flex: none; }
.card input[type="text"] { flex: 1; font-size: 15px; }

.source-select { width: 100%; margin-bottom: 18px; }
.read-body p { font-size: 19px; line-height: 1.65; margin: 0 0 22px; letter-spacing: -.01em; }
.read-body p:nth-child(even) { color: #ded3c2; }

.settings-row.column { flex-direction: column; align-items: stretch; gap: 10px; }
.settings-row.column select, .settings-row.column .ghost-btn { max-width: none; width: 100%; margin: 0; }
.range-wrap { display: flex; align-items: center; gap: 12px; flex: 0 1 220px; }
.range-wrap b { font-size: 13px; color: var(--text-muted); min-width: 42px; text-align: right; font-weight: 500; }
input[type="range"] { padding: 0; accent-color: var(--accent); background: none; border: none; width: 100%; }

/* ---- Barre d'onglets (mobile) ---- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center; gap: 2px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}
.tab { flex: 1 1 0; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; color: var(--text-muted); font-size: 10.5px; border-radius: 12px; }
.tab .ic { width: 21px; height: 21px; }
.tab.active { color: var(--accent); }

/* ---- Choix des voix ---- */
.voice-row { width: 100%; text-align: left; cursor: pointer; }
.voice-current { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 14px; }
.voice-current::after { content: '›'; font-size: 19px; line-height: 1; color: var(--text-muted); }
.voice-list { display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; }
.voice-group { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--text-muted); margin: 14px 4px 6px; }
.voice-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; border: 1px solid transparent; }
.voice-item:hover { background: rgba(255,225,180,.04); }
.voice-item.on { border-color: rgba(226,169,93,.45); background: rgba(226,169,93,.10); }
.voice-pick { flex: 1; display: flex; flex-direction: column; gap: 2px; text-align: left; min-width: 0; }
.voice-name { font-size: 15px; }
.voice-item.on .voice-name { color: var(--accent); }
.voice-note { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-act { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); flex: none; }
.voice-act .ic { width: 19px; height: 19px; }
.voice-act.fav-on { color: var(--accent); }
.voice-act.fav-on .ic { fill: var(--accent); }

/* ---- Lecteur d'affirmations ---- */
#screen-aff-player { display: flex; flex-direction: column; justify-content: flex-start; padding: max(20px, env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom)); background: radial-gradient(120% 80% at 50% 0%, #2a1d10 0%, var(--bg) 62%); }
.aff-close { align-self: flex-end; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.aff-player-inner { flex: 1; width: 100%; max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; }
.aff-source { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .09em; margin: 0 0 auto; }
.aff-text { font-size: clamp(23px, 6vw, 34px); line-height: 1.4; font-weight: 400; letter-spacing: -.01em; margin: 32px 0; text-wrap: balance; }
.aff-bottom { margin-top: auto; }

/* Barre de progression : un input range déguisé, pour pouvoir se déplacer au doigt. */
.aff-seek { margin-bottom: 6px; }
#aff-seek { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; padding: 0; border: none; background: none; }
#aff-seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--played, 0%), rgba(255,225,180,.18) var(--played, 0%)); }
#aff-seek::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,225,180,.18); }
#aff-seek::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
#aff-seek::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: var(--text); }
#aff-seek::-moz-range-thumb { width: 12px; height: 12px; border: none; border-radius: 50%; background: var(--text); }
.aff-times { display: flex; justify-content: space-between; align-items: baseline; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; margin-bottom: 18px; }

.aff-buttons { display: flex; align-items: center; justify-content: center; gap: 18px; }
.aff-nav { color: var(--text); width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; }
.aff-nav .ic { width: 26px; height: 26px; }
.aff-side { color: var(--text-muted); width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; position: relative; }
.aff-side .ic { width: 20px; height: 20px; }
.aff-side.on { color: var(--accent); }
.aff-side.on::after { content: ''; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.aff-play { width: 74px; height: 74px; border-radius: 50%; background: var(--grad); color: #231507; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 10px 34px rgba(226,169,93,.24); }
.aff-play .ic { width: 30px; height: 30px; stroke-width: 2; }
.aff-toggles { display: flex; justify-content: center; gap: 10px; margin-top: 22px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); font-size: 13px; }
.chip .ic { width: 16px; height: 16px; }
.chip.on { color: var(--accent); border-color: rgba(226,169,93,.4); }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 90; max-width: calc(100vw - 40px); text-align: center;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 14px;
  padding: 11px 18px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

/* ============================================================
   DESKTOP — vraie app avec barre latérale
   ============================================================ */
@media (min-width: 1000px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: revert; }

  #app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

  #sidebar {
    display: flex !important; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    padding: 26px 18px calc(20px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, #1a140e, #120e0a);
    border-right: 1px solid var(--border);
  }
  .brand { display: flex; align-items: center; gap: 11px; font-size: 19px; letter-spacing: .08em; padding: 0 8px 24px; }
  .brand-logo { width: 34px; height: 34px; border-radius: 10px; }
  .side-nav { display: flex; flex-direction: column; gap: 4px; }
  .nav-group { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--text-muted); padding: 14px 14px 4px; }
  .nav-group:first-child { padding-top: 0; }
  .nav-sep { height: 1px; background: var(--border); margin: 12px 14px; }
  /* .nav-link = même allure que .nav-item, mais c'est un vrai lien vers l'autre moitié de
     l'app (les affirmations), pas un changement d'écran géré par app.js. */
  .nav-item, .nav-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; color: var(--text-muted); font-size: 14.5px; text-align: left; text-decoration: none; transition: background .18s, color .18s; }
  .nav-item .ic, .nav-link .ic { width: 20px; height: 20px; }
  .nav-item:hover, .nav-link:hover { color: var(--text); background: rgba(255,225,180,.04); }
  .nav-item.active { color: var(--accent); background: rgba(226,169,93,.12); }
  .sidebar-streak { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: rgba(226,169,93,.06); font-size: 14px; }
  .sidebar-streak .ic { width: 22px; height: 22px; }
  .sidebar-streak b { font-size: 17px; }

  #main { min-width: 0; overflow-x: hidden; }

  .view { min-height: 100vh; max-width: none; margin: 0; padding: 40px 44px 60px; }
  #screen-home { overflow: visible; }
  .home-glow { top: -220px; width: 720px; }

  .home-layout { display: flex; gap: 40px; align-items: flex-start; }
  .cal-column { flex: 0 0 auto; width: min(48vw, 600px); }
  .calendar-grid { gap: 8px; }
  .day-cell { font-size: 14px; border-radius: 14px; }
  .day-cell:hover { box-shadow: inset 0 0 0 1px var(--accent); }
  #month-label { font-size: 16px; }

  .day-panel { flex: 1 1 300px; align-self: stretch; border: 1px solid var(--border); border-radius: 20px; background: var(--glass-bg); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); padding: 22px; min-height: 240px; }

  .screen-h1 { display: none; }

  #screen-new { max-width: 1180px; }
  #guide-panel { max-width: 620px; }
  .choose-layout { display: flex; gap: 32px; align-items: flex-start; }
  #type-chips { flex: 1 1 auto; grid-template-columns: repeat(3, 1fr); }
  .type-detail { flex: 0 0 380px; border: 1px solid var(--border); border-radius: 20px; background: var(--glass-bg); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); padding: 22px; min-height: 420px; }
  .type-detail-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; color: var(--text-muted); height: 100%; min-height: 380px; padding: 20px; }
  .type-detail-empty .ic { color: var(--accent); opacity: .6; }
  .type-detail-empty p { font-size: 14px; line-height: 1.5; max-width: 220px; }
  .td-back { display: none; }

  #screen-settings { max-width: 620px; }
  #screen-preview { max-width: 760px; }
  #screen-library, #screen-playlists, #screen-playlist, #screen-read { max-width: 760px; }
  .screen-title { font-size: 24px; }
  .toast { bottom: 32px; }
  .hero { height: 300px; border-radius: 0 0 26px 26px; }
  .hero-spacer { height: 200px; }

  #modal-detail {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    max-width: 460px; width: 92vw; max-height: 84vh;
    border-radius: 20px; border: 1px solid var(--border);
    animation: modal-in .2s ease-out;
  }
  #modal-detail .sheet-handle { display: none; }
  @keyframes modal-in { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; transform: translate(-50%, -50%); } }

  .type-card, .preset-card, .day-cell, .session-row, .mode-btn, .duration-row button, .nav-item, .switch { cursor: pointer; }
}

/* Sur mobile, le panneau de détail type devient un plein-écran superposé */
@media (max-width: 999px) {
  #type-detail { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; padding: calc(16px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom)); transform: translateX(100%); transition: transform .26s ease; }
  #type-detail.open { transform: translateX(0); }

  /* La barre d'onglets est fixe : chaque écran lui laisse sa place, et le bouton
     « nouvelle méditation » remonte au-dessus d'elle. */
  .view { padding-bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
  .fab { bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); }
  .sheet { padding-bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom)); }
}
