:root {
  --bg: #0f1419;
  --surface: #1a222c;
  --surface-2: #232e3a;
  --border: #2c3a48;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3fb950;
  --accent-2: #58a6ff;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(0,0,0,.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px calc(14px);
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(15,20,25,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -.5px; }
.topbar h1 span { color: var(--accent); }
.top-stat { font-size: .8rem; color: var(--muted); text-align: right; line-height: 1.3; }
.top-stat b { color: var(--text); font-size: .95rem; }

/* ---------- Layout ---------- */
main { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1rem; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h3 { font-size: .85rem; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }
.muted { color: var(--muted); font-size: .85rem; }
.center { text-align: center; }

/* ---------- Stats en gros ---------- */
.big-stat { text-align: center; padding: 8px 0; }
.big-stat .val { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.big-stat .val small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.big-stat .lbl { color: var(--muted); font-size: .85rem; margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.stat-box { background: var(--surface-2); border-radius: 12px; padding: 12px; text-align: center; }
.stat-box .v { font-size: 1.4rem; font-weight: 700; }
.stat-box .l { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.stat-box .v.accent { color: var(--accent); }
.stat-box .v.blue { color: var(--accent-2); }
.stat-box .v.warn { color: var(--warn); }

/* ---------- Formulaires ---------- */
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 14px; }
input, select, textarea {
  width: 100%; padding: 12px; font-size: 1rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

button.btn {
  width: 100%; padding: 13px; font-size: 1rem; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: #06210c;
  transition: filter .15s;
}
button.btn:active { filter: brightness(.9); }
button.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.btn.blue { background: var(--accent-2); color: #06121f; }
button.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.btn.small { padding: 9px; font-size: .85rem; width: auto; }

.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 9px; border: none; background: transparent; color: var(--muted); border-radius: 7px; font-size: .9rem; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--accent); color: #06210c; }

/* ---------- Listes ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface-2); border-radius: 10px; padding: 12px;
}
.item .t { font-weight: 600; font-size: .95rem; }
.item .s { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.item .cal { color: var(--accent); font-weight: 700; white-space: nowrap; }
.item .x { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }
.badge { display: inline-block; font-size: .68rem; padding: 3px 8px; border-radius: 20px; background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.badge.hot { color: var(--accent); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---------- Graphique poids ---------- */
.chart { width: 100%; height: 180px; }
.chart-empty { height: 180px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; }

/* ---------- Barre de progression ---------- */
.progress { height: 10px; background: var(--surface-2); border-radius: 20px; overflow: hidden; margin: 8px 0; }
.progress .fill { height: 100%; background: linear-gradient(90deg,var(--accent),#2ea043); border-radius: 20px; transition: width .4s; }

/* ---------- Minuteur ---------- */
.timer-display { font-size: 4rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: -2px; }
.timer-display.rest { color: var(--warn); }
.timer-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 640px; margin: 0 auto;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; color: var(--muted);
  padding: 10px 4px 8px; font-size: .68rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-weight: 600;
}
.tab span { font-size: 1.35rem; }
.tab.active { color: var(--accent); }

/* ---------- Divers ---------- */
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .ico { font-size: 2.5rem; margin-bottom: 10px; }
.spacer { height: 4px; }
.fade { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #06210c; padding: 10px 18px; border-radius: 30px;
  font-weight: 600; font-size: .9rem; z-index: 50; box-shadow: var(--shadow);
  animation: toast 2.2s ease forwards;
}
@keyframes toast { 0%{opacity:0;transform:translate(-50%,10px)} 15%,80%{opacity:1;transform:translate(-50%,0)} 100%{opacity:0} }
