/* SOUFFLE — thème « grand air » : papier vert d'eau, encre profonde, teal apaisant */

@font-face { font-family: 'Lora'; src: url('/fonts/lora-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Raleway'; src: url('/fonts/raleway-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Raleway'; src: url('/fonts/raleway-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --paper: #F2F7F5;
  --card: #FFFFFF;
  --ink: #14332F;
  --ink-80: rgba(20, 51, 47, 0.8);
  --ink-60: rgba(20, 51, 47, 0.62);
  --teal: #0B6B5D;
  --teal-deep: #0B3B36;
  --teal-soft: #E1EFEB;
  --green: #1E8A5D;
  --green-soft: #E3F3EA;
  --warm: #B4552D;
  --warm-soft: #F8E9E1;
  --gold: #A16207;
  --gold-soft: #F6EDDA;
  --border: #DCE8E4;
  --shadow: 0 2px 10px rgba(11, 59, 54, 0.07), 0 8px 28px rgba(11, 59, 54, 0.05);
  --r-lg: 20px; --r-md: 14px; --r-sm: 10px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --font-body: 'Raleway', 'Segoe UI', system-ui, sans-serif;
  --font-title: 'Lora', Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body); font-size: 16px; line-height: 1.55;
  background: var(--paper); color: var(--ink);
  min-height: 100dvh;
}
h1, h2, h3 { font-family: var(--font-title); font-weight: 600; line-height: 1.25; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
button { font-family: inherit; font-size: 1rem; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 16px; color: var(--ink);
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; background: #fff; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(11, 107, 93, 0.45); outline-offset: 2px;
}
svg { width: 22px; height: 22px; flex: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-60); font-size: 0.94rem; }

/* ---------- coquille ---------- */
.shell { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + var(--sp-3)) var(--sp-4) var(--sp-3);
  position: sticky; top: 0; z-index: 20;
  background: rgba(242, 247, 245, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); font-family: var(--font-title); font-weight: 600; font-size: 1.1rem; letter-spacing: 0.06em; color: var(--teal-deep); }
.brand img { border-radius: 8px; }
.topbar-day { font-weight: 600; color: var(--teal); font-variant-numeric: tabular-nums; }

#main { flex: 1; padding: var(--sp-4) var(--sp-4) calc(env(safe-area-inset-bottom) + 96px); }

.bottombar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 1px solid var(--border);
  padding: var(--sp-1) var(--sp-2) calc(env(safe-area-inset-bottom) + var(--sp-1));
  box-shadow: 0 -4px 20px rgba(11, 59, 54, 0.08);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--sp-2) 0; min-height: 52px; color: var(--ink-60);
  font-size: 0.7rem; font-weight: 600; border-radius: var(--r-sm);
  transition: color 0.2s;
}
.nav-btn.active { color: var(--teal); }
.nav-sos {
  color: #fff; background: var(--teal); border-radius: 999px;
  margin: -18px 6px 2px; padding: var(--sp-3) 0; min-height: 62px;
  box-shadow: 0 6px 16px rgba(11, 107, 93, 0.35);
}
.nav-sos.active, .nav-sos:active { background: var(--teal-deep); color: #fff; }
.nav-sos svg { width: 26px; height: 26px; }

/* ---------- cartes & boutons ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-5); margin-bottom: var(--sp-4); box-shadow: var(--shadow);
}
.card-title { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); color: var(--teal-deep); }
.page-title { margin: var(--sp-2) 0 var(--sp-4); color: var(--teal-deep); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  border-radius: var(--r-md); padding: 14px 20px; font-weight: 600; min-height: 48px;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-primary { background: var(--teal); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 3px 10px rgba(11,107,93,0.25); }
.btn-primary:hover { background: var(--teal-deep); }
.btn-outline { border: 1.5px solid var(--teal); color: var(--teal); background: #fff; }
.btn-ghost { color: var(--ink-60); background: transparent; }
.btn-ghost:hover { color: var(--ink); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- connexion ---------- */
.login-body { display: grid; place-items: center; padding: var(--sp-5); background: linear-gradient(170deg, #E8F2EE 0%, var(--paper) 55%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--sp-6); text-align: center; }
.login-logo img { border-radius: 18px; }
.login-title { letter-spacing: 0.14em; color: var(--teal-deep); margin: var(--sp-3) 0 var(--sp-1); }
.login-sub { color: var(--ink-60); margin-bottom: var(--sp-5); }
.login-card form { text-align: left; display: grid; gap: var(--sp-2); }
.login-card label { font-weight: 600; font-size: 0.9rem; margin-top: var(--sp-2); }
.form-error { color: var(--warm); font-weight: 600; margin: var(--sp-2) 0; }

/* ---------- accueil ---------- */
.home-hero { text-align: center; padding: var(--sp-3) 0 var(--sp-4); }
.phase-chip {
  display: inline-block; background: var(--teal-soft); color: var(--teal-deep);
  font-weight: 600; font-size: 0.85rem; border-radius: 999px; padding: 6px 16px; margin-bottom: var(--sp-4);
}
.dayring { position: relative; width: 132px; margin: 0 auto var(--sp-3); }
.dayring svg { width: 132px; height: 132px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--teal-soft); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--teal); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 327; transition: stroke-dashoffset 0.8s ease; }
.dayring-txt { position: absolute; inset: 0; display: grid; place-content: center; }
.dayring-txt strong { font-family: var(--font-title); font-size: 2.2rem; color: var(--teal-deep); line-height: 1; }
.dayring-txt span { color: var(--ink-60); font-size: 0.85rem; }
.daily-msg { max-width: 42ch; margin: 0 auto; color: var(--ink-80); }

.btn-sos-hero {
  width: 100%; display: flex; align-items: center; gap: var(--sp-4);
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 100%); color: #fff;
  border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-4);
  box-shadow: 0 8px 24px rgba(11, 107, 93, 0.35), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.15s;
}
.btn-sos-hero:active { transform: scale(0.98); }
.btn-sos-hero svg { width: 34px; height: 34px; }
.btn-sos-hero span { display: flex; flex-direction: column; text-align: left; }
.btn-sos-hero strong { font-size: 1.2rem; font-family: var(--font-title); }
.btn-sos-hero small { opacity: 0.85; }

.gauge { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-4); box-shadow: var(--shadow); }
.gauge-head { display: flex; justify-content: space-between; font-size: 0.95rem; margin-bottom: var(--sp-2); }
.gauge-bar { height: 12px; border-radius: 999px; background: var(--teal-soft); overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 999px; background: var(--green); transition: width 0.4s ease; min-width: 4px; }
.gauge-over .gauge-fill { background: var(--warm); }
.gauge-note { margin-top: var(--sp-2); font-size: 0.88rem; color: var(--ink-60); }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-2); text-align: center; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.stat-ico { color: var(--teal); margin-bottom: 2px; }
.stat strong { font-family: var(--font-title); font-size: 1.15rem; color: var(--teal-deep); }
.stat span { font-size: 0.78rem; color: var(--ink-60); }

.health-card { cursor: pointer; }
.mini-bar { height: 8px; border-radius: 999px; background: var(--teal-soft); overflow: hidden; margin-top: var(--sp-2); }
.mini-bar > div { height: 100%; background: var(--teal); border-radius: 999px; min-width: 3px; transition: width 0.4s; }

.btn-smoked {
  width: 100%; min-height: 48px; border: 1.5px dashed var(--border); border-radius: var(--r-md);
  color: var(--ink-60); font-weight: 600; background: transparent; margin-top: var(--sp-2);
}
.btn-smoked:hover { border-color: var(--warm); color: var(--warm); }
.smoked-hint { font-size: 0.8rem; color: var(--ink-60); text-align: center; margin-top: var(--sp-2); padding: 0 var(--sp-4); }
.hero-setup { text-align: center; padding-top: var(--sp-5); }
.hero-setup img { border-radius: 16px; margin-bottom: var(--sp-4); }
.hero-setup .card { text-align: left; }

/* ---------- SOS ---------- */
.sos-head { text-align: center; padding: var(--sp-4) 0; }
.sos-head h2 { color: var(--teal-deep); margin-bottom: var(--sp-2); }
.intensity-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--sp-2); }
.int-btn {
  background: var(--card); border: 1.5px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-4) 0 var(--sp-3); display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 76px; transition: transform 0.15s, border-color 0.2s;
}
.int-btn:active { transform: scale(0.95); }
.int-btn strong { font-family: var(--font-title); font-size: 1.4rem; color: var(--teal-deep); }
.int-btn span { font-size: 0.68rem; color: var(--ink-60); }
.int-4, .int-5 { border-color: #EAD9CE; }
.int-btn:hover { border-color: var(--teal); }

.chip-grid { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; }
.chip {
  background: var(--card); border: 1.5px solid var(--border); border-radius: 999px;
  padding: 12px 18px; font-weight: 600; font-size: 0.92rem; min-height: 46px;
  transition: border-color 0.2s, background 0.2s;
}
.chip:hover, .chip:active { border-color: var(--teal); background: var(--teal-soft); }

.coach-screen { display: flex; flex-direction: column; gap: var(--sp-4); padding-top: var(--sp-3); }
.coach-msg {
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--teal);
  border-radius: var(--r-md); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow);
  font-size: 1.02rem; color: var(--ink-80);
}
.reason-box {
  display: flex; gap: var(--sp-3); align-items: center;
  background: var(--gold-soft); border-radius: var(--r-md); padding: var(--sp-4) var(--sp-5); color: #6b4a10;
}
.reason-box svg { color: var(--gold); }
.reason-box span { display: block; font-size: 0.8rem; opacity: 0.8; }
.tech-box { background: var(--green-soft); border-radius: var(--r-md); padding: var(--sp-4) var(--sp-5); color: #14532d; }
.tech-tag { display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.7; margin-bottom: 2px; }
.tech-box strong { display: block; margin-bottom: 4px; }
.tech-box p { font-size: 0.92rem; }

.breath-zone { text-align: center; padding: var(--sp-4) 0 var(--sp-2); }
.breath-circle {
  width: 170px; height: 170px; margin: 0 auto var(--sp-3); border-radius: 50%;
  display: grid; place-content: center; padding: var(--sp-4);
  background: radial-gradient(circle at 38% 32%, #9CC8BC 0%, var(--teal) 65%, var(--teal-deep) 100%);
  color: #fff; font-weight: 600; box-shadow: 0 10px 30px rgba(11, 107, 93, 0.35);
  transform: scale(1); transition: transform 4.6s ease-in-out;
}
.breath-circle.inhale { transform: scale(1.3); }
.countdown { color: var(--ink-60); font-size: 0.92rem; }
.countdown span { font-weight: 700; color: var(--teal-deep); font-variant-numeric: tabular-nums; }
.sos-actions { display: grid; gap: var(--sp-2); padding-bottom: var(--sp-4); }

.sos-done { text-align: center; padding: var(--sp-6) var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-4); align-items: center; }
.sos-done-ico { width: 72px; height: 72px; border-radius: 50%; display: grid; place-content: center; }
.sos-win .sos-done-ico { background: var(--green-soft); color: var(--green); }
.sos-soft .sos-done-ico { background: var(--warm-soft); color: var(--warm); }
.sos-done-ico svg { width: 34px; height: 34px; }
.sos-done-stats { color: var(--ink-60); }

/* ---------- progrès ---------- */
.chart { display: flex; gap: 2px; align-items: stretch; height: 150px; margin-top: var(--sp-3); }
.col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.col-area { position: relative; flex: 1; background: #F7FAF9; border-radius: 4px 4px 0 0; overflow: hidden; }
.col-today .col-area { background: var(--teal-soft); }
.col-ceil { position: absolute; left: 0; right: 0; border-top: 2px dashed rgba(11, 107, 93, 0.5); }
.col-bar { position: absolute; bottom: 0; left: 15%; right: 15%; background: var(--green); border-radius: 3px 3px 0 0; }
.col-bar.over { background: var(--warm); }
.col-lbl { font-size: 0.62rem; color: var(--ink-60); text-align: center; height: 14px; }

.health-list { list-style: none; margin-top: var(--sp-3); }
.health-list li { display: flex; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); opacity: 0.55; }
.health-list li:last-child { border-bottom: none; }
.health-list li.done, .health-list li.next { opacity: 1; }
.h-dot {
  width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px solid var(--border);
  display: grid; place-content: center; background: #fff; margin-top: 2px;
}
.health-list li.done .h-dot { background: var(--green); border-color: var(--green); color: #fff; }
.health-list li.next .h-dot { border-color: var(--teal); }
.h-dot svg { width: 14px; height: 14px; }
.health-list p { font-size: 0.88rem; color: var(--ink-60); }

.trig-row { margin-bottom: var(--sp-3); }
.trig-head { display: flex; justify-content: space-between; font-size: 0.92rem; margin-bottom: 4px; }
.advice { margin-top: var(--sp-3); background: var(--teal-soft); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); font-size: 0.92rem; color: var(--teal-deep); }

.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); margin-top: var(--sp-3); }
.badge-item {
  border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3);
  display: flex; flex-direction: column; gap: 2px; opacity: 0.45; text-align: center; align-items: center;
}
.badge-item svg { color: var(--border); width: 26px; height: 26px; }
.badge-item.earned { opacity: 1; border-color: var(--gold); background: var(--gold-soft); }
.badge-item.earned svg { color: var(--gold); }
.badge-item strong { font-size: 0.86rem; }
.badge-item span { font-size: 0.72rem; color: var(--ink-60); }

/* ---------- journal ---------- */
.mood-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--sp-2); margin: var(--sp-3) 0; }
.mood-btn {
  border: 1.5px solid var(--border); border-radius: var(--r-md); background: var(--card);
  padding: var(--sp-3) 0; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px;
}
.mood-btn span { font-size: 0.62rem; color: var(--ink-60); }
.mood-btn strong { font-family: var(--font-title); color: var(--teal-deep); }
.mood-btn.sel { border-color: var(--teal); background: var(--teal-soft); }
#checkin-note { margin-bottom: var(--sp-3); resize: vertical; }

.day-card { padding: var(--sp-4) var(--sp-5); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.day-head h3 { text-transform: capitalize; font-size: 0.98rem; }
.day-sums { display: flex; gap: var(--sp-2); font-size: 0.8rem; }
.day-sums em { font-style: normal; font-weight: 700; border-radius: 999px; padding: 2px 10px; }
.day-sums .ok { background: var(--green-soft); color: var(--green); }
.day-sums .ko { background: var(--warm-soft); color: var(--warm); }
.day-mood { font-size: 0.88rem; color: var(--ink-60); margin-bottom: var(--sp-2); }
.entry { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-top: 1px solid var(--border); font-size: 0.92rem; }
.entry-time { color: var(--ink-60); font-size: 0.82rem; width: 44px; flex: none; }
.entry-txt { flex: 1; }
.entry.resisted .entry-txt { color: var(--green); font-weight: 600; }
.entry.smoked .entry-txt { color: var(--ink-80); }
.entry-del { color: var(--ink-60); opacity: 0.6; padding: var(--sp-2); min-width: 40px; min-height: 40px; display: grid; place-content: center; border-radius: var(--r-sm); }
.entry-del:hover { opacity: 1; color: var(--warm); }
.entry-del svg { width: 17px; height: 17px; }

/* ---------- réglages ---------- */
.form-grid { display: grid; gap: var(--sp-3); margin-top: var(--sp-3); }
.form-grid label { font-weight: 600; font-size: 0.9rem; display: grid; gap: 6px; }
.reason-list { list-style: none; margin: var(--sp-3) 0; }
.reason-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.reason-list li:last-child { border-bottom: none; }
.inline-form { display: flex; gap: var(--sp-2); }
.inline-form .btn { min-width: 52px; padding: 0; }
.users-list { margin: var(--sp-3) 0; }
.user-row { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.user-row em { font-style: normal; font-size: 0.78rem; color: var(--ink-60); background: var(--teal-soft); border-radius: 999px; padding: 2px 10px; margin-left: var(--sp-2); }
.about p { font-size: 0.88rem; }

/* ---------- toast & badge ---------- */
.toast {
  position: fixed; bottom: calc(env(safe-area-inset-bottom) + 104px); left: 50%; transform: translateX(-50%);
  background: var(--teal-deep); color: #fff; border-radius: var(--r-md); padding: var(--sp-3) var(--sp-5);
  box-shadow: 0 8px 24px rgba(11, 59, 54, 0.35); z-index: 60; max-width: min(92vw, 480px); text-align: center; font-size: 0.94rem;
}
.toast-err { background: var(--warm); }
.toast-soft { background: var(--gold); }
.badge-pop {
  position: fixed; top: calc(env(safe-area-inset-top) + 70px); left: 50%; transform: translateX(-50%);
  z-index: 70; width: min(92vw, 420px);
}
.badge-pop-inner {
  display: flex; gap: var(--sp-3); align-items: center;
  background: var(--gold-soft); border: 1.5px solid var(--gold); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow); color: #6b4a10;
}
.badge-pop-inner svg { color: var(--gold); width: 30px; height: 30px; }
.badge-pop-inner strong { display: block; }
.badge-pop-inner span { font-size: 0.85rem; }

.loading { text-align: center; padding: var(--sp-6); }

/* ---------- accessibilité & mouvements ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
@media (min-width: 600px) {
  body { background: linear-gradient(170deg, #E8F2EE 0%, var(--paper) 45%); }
  .shell { border-left: 1px solid var(--border); border-right: 1px solid var(--border); background: var(--paper); }
}
