/* =====================================================================
   Grinduo : styles. Mobile d'abord (iPhone), clair + sombre.
   ===================================================================== */
:root, :root[data-theme="light"] {
  --bg: #f3f1ec; --surface: #ffffff; --surface-2: #f8f6f2; --ink: #17140f; --muted: #6f6a62; --line: #e4e0d8;
  --accent: #ee5410; --accent-ink: #ffffff; --accent-soft: #fde7da; --ring-bg: #ece8e0;
  --danger: #c3362c; --shadow: 0 1px 2px rgba(23, 20, 15, .06), 0 6px 20px rgba(23, 20, 15, .05);
}
:root[data-theme="dark"] {
  --bg: #0d0d0f; --surface: #17171a; --surface-2: #1f1f23; --ink: #f4f2ee; --muted: #9b978f; --line: #2a2a30;
  --accent: #ff6a1f; --accent-ink: #160a03; --accent-soft: rgba(255, 106, 31, .15); --ring-bg: #26262b;
  --danger: #ff6b5e; --shadow: none;
}
:root {
  --display: "Archivo", "Arial Black", system-ui, sans-serif;
  --body: "Manrope", system-ui, -apple-system, sans-serif;
  --r: 16px;
  color-scheme: light dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink); font: 500 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- logo ---------- */
.logo { font: 900 22px/1 var(--display); font-stretch: 125%; letter-spacing: -.01em; }
.logo b { color: var(--accent); font-weight: inherit; }
.splash { min-height: 100dvh; display: grid; place-items: center; }
.splash .logo { font-size: 34px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- structure ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px; background: var(--bg);
  max-width: 560px; margin: 0 auto;
}
.who { color: var(--muted); font-weight: 700; font-size: 14px; }
.main { max-width: 560px; margin: 0 auto; padding: 4px 16px calc(env(safe-area-inset-bottom) + 96px); display: grid; gap: 12px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav button {
  flex: 1; max-width: 170px; display: grid; justify-items: center; gap: 2px; padding: 6px 4px;
  border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 700; border-radius: 12px;
}
.nav button.on { color: var(--accent); }

/* ---------- cartes et textes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
h2 { font: 800 18px/1.2 var(--display); font-stretch: 112%; margin: 0 0 12px; display: flex; gap: 8px; align-items: baseline; }
h2 .muted { font: 600 14px var(--body); }
.section-title { font: 800 13px var(--body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 10px 2px 0; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.eyebrow { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* ---------- boutons et champs ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface-2); padding: 11px 16px; border-radius: 12px;
  font-weight: 800; white-space: nowrap; transition: transform .08s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.link { border: 0; background: none; padding: 4px 0; color: var(--accent); font-weight: 700; font-size: 14px; }
.link.danger { color: var(--danger); }
.icon { border: 0; background: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--ink); }
.icon:not(:disabled):active { background: var(--surface-2); }

input {
  width: 100%; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 16px; /* 16px : évite le zoom auto sur iPhone */
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input { flex: 1 1 160px; }
.row + .row { margin-top: 10px; }

/* ---------- aujourd'hui ---------- */
.daynav { display: flex; align-items: center; justify-content: space-between; }
.daylabel { text-align: center; font: 800 17px var(--display); font-stretch: 108%; display: grid; justify-items: center; }
.daylabel .link { font: 700 12.5px var(--body); }

.score { display: flex; align-items: center; gap: 18px; }
.ringwrap { position: relative; width: 112px; height: 112px; flex: none; }
.ring { width: 112px; height: 112px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring-bg { stroke: var(--ring-bg); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .35s ease; }
.ringtxt { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ringtxt strong { font: 900 30px/1 var(--display); font-stretch: 115%; }
.ringtxt small, .big small { font-size: .55em; margin-left: 1px; }
.ringtxt span { font-size: 13px; font-weight: 700; color: var(--muted); }
.month { flex: 1; display: grid; gap: 4px; min-width: 0; }
.big { font: 900 28px/1 var(--display); font-stretch: 115%; }

.bar { height: 8px; border-radius: 99px; background: var(--ring-bg); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .35s ease; }

.list { display: grid; gap: 8px; }
.habit {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 14px; min-height: 60px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: background .15s, border-color .15s, transform .08s;
}
.habit:active { transform: scale(.985); }
.habit .box {
  width: 28px; height: 28px; flex: none; border-radius: 9px; border: 2px solid var(--line);
  display: grid; place-items: center; color: transparent; transition: all .15s;
}
.habit .box svg { width: 18px; height: 18px; stroke-width: 3; }
.habit.on { background: var(--accent-soft); border-color: transparent; }
.habit.on .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.habit .txt, .hlist .txt { flex: 1; min-width: 0; display: grid; }
.name { font-weight: 800; }
.note { font-size: 13px; color: var(--muted); font-weight: 500; }
.streak { font-weight: 800; font-size: 14px; white-space: nowrap; }

.empty { text-align: center; padding: 28px 20px; }
.empty h2 { justify-content: center; font-size: 22px; }
.empty p { color: var(--muted); margin-bottom: 16px; }

.duo-cta { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.duo-cta p { margin: 2px 0 0; }
.partner { display: grid; gap: 8px; }
.p-head { display: flex; justify-content: space-between; align-items: baseline; }
.p-count { font: 900 20px var(--display); }
.code { font: 800 15px ui-monospace, "SF Mono", monospace; letter-spacing: .12em; color: var(--accent); }
.big-code { border: 1px dashed var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 8px; margin-left: 4px; }

/* ---------- habitudes ---------- */
.hlist { list-style: none; margin: 0; padding: 0; display: grid; }
.hlist li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.hlist li:first-child { border-top: 0; }
.hlist li.editing { display: block; }
.tools { display: flex; flex: none; }
.tools .icon { width: 36px; height: 36px; color: var(--muted); }
.tools svg { width: 19px; height: 19px; }

/* ---------- profil ---------- */
.members { margin: 8px 0 12px; padding-left: 18px; }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* ---------- connexion ---------- */
.auth {
  min-height: 100dvh; max-width: 400px; margin: 0 auto; padding: 24px 16px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px;
}
.auth .logo { font-size: 44px; }
.auth .tag { color: var(--muted); font-weight: 700; margin: -6px 0 10px; }
.auth form { width: 100%; }

/* ---------- message ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
  opacity: 0; transition: all .25s; z-index: 20; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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