/* ===== Design tokens =====
   Fond quasi-noir : #0B0F0E
   Surface (cartes) : #141B19
   Surface élevée   : #1B2422
   Accent effort/brûlé : #FF5A36 (orange chaud)
   Accent déficit/objectif : #6EE7B7 (vert menthe)
   Texte principal : #F2F5F3
   Texte atténué : #8A948F
   Display : 'Space Grotesk' — Body : 'Inter' — Data : 'JetBrains Mono'
*/

:root {
  --bg: #0B0F0E;
  --surface: #141B19;
  --surface-hi: #1B2422;
  --surface-hi-2: #212B29;
  --border: #263230;
  --border-soft: #1D2725;
  --orange: #FF5A36;
  --orange-soft: #FFC24B;
  --green: #6EE7B7;
  --text: #F2F5F3;
  --text-dim: #8A948F;
  --text-faint: #5C6663;
  --red: #FF5A5A;
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 12% 8%, rgba(255,90,54,0.05), transparent 32%),
    radial-gradient(circle at 88% 18%, rgba(110,231,183,0.045), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(110,231,183,0.03), transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3, .display {
  font-family: 'Space Grotesk', sans-serif;
}

button { font-family: inherit; }

::selection { background: var(--orange); color: #0B0F0E; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ===================== AUTH SCREEN ===================== */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,90,54,0.08), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(110,231,183,0.06), transparent 45%),
    var(--bg);
}
.auth-screen[hidden] { display: none; }

.auth-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--surface-hi-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 30px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.03);
  animation: authIn 0.5s var(--ease);
}

@keyframes authIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 10px;
  justify-content: center;
}
.auth-brand-arrow { color: var(--text-faint); font-size: 22px; }
.auth-brand .accent {
  background: linear-gradient(120deg, var(--green), #9FF2CE);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-sub {
  text-align: center;
  color: var(--text-dim);
  margin: 10px 0 30px;
  font-size: 13.5px;
  letter-spacing: 0.01em;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.field input, .field select {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.field input:hover, .field select:hover { border-color: #38443F; }
.field input:focus, .field select:focus { border-color: var(--green); background: var(--surface-hi-2); }

.auth-error {
  color: var(--red);
  font-size: 13px;
  margin: 0;
}

.btn {
  border: none;
  border-radius: 11px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 0.01em;
  transition: transform 0.12s var(--ease), box-shadow 0.2s var(--ease), opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, #85F0C4, var(--green));
  color: #05130E;
  box-shadow: 0 6px 20px -6px rgba(110,231,183,0.45);
}
.btn-primary:hover { box-shadow: 0 8px 24px -6px rgba(110,231,183,0.6); transform: translateY(-1px); }
.btn-ghost { background: transparent; border: 1px dashed var(--border); color: var(--text-dim); }
.btn-ghost:hover { border-color: var(--green); color: var(--text); background: rgba(110,231,183,0.04); }
.btn-block { width: 100%; }

.link-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 16px;
  cursor: pointer;
  text-decoration: underline;
}

/* ===================== APP SHELL ===================== */
.app { min-height: 100dvh; padding-bottom: 40px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11,15,14,0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.topbar-brand {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-shrink: 0;
  padding-right: 18px;
  border-right: 1px solid var(--border-soft);
}
.topbar-num.accent { color: var(--green); }
.topbar-sep { color: var(--text-faint); }
.topbar-unit { color: var(--text-dim); font-size: 11px; margin-left: 2px; }

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.tab-ico { font-size: 12px; opacity: 0.75; }
.tab-btn.is-active { background: var(--surface-hi); color: var(--text); }
.tab-btn.is-active .tab-ico { color: var(--green); opacity: 1; }
.tab-btn:hover:not(.is-active) { color: var(--text); background: rgba(255,255,255,0.03); }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s var(--ease);
}
.icon-btn:hover { color: var(--red); border-color: var(--red); background: rgba(255,90,90,0.06); }

.views { max-width: 760px; margin: 0 auto; padding: 22px 20px 60px; }

.view { display: none; flex-direction: column; gap: 16px; }
.view.is-active { display: flex; animation: viewIn 0.35s var(--ease); }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================== CARDS ===================== */
.card {
  background: linear-gradient(180deg, var(--surface-hi-2) 0%, var(--surface) 140px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 20px 40px -28px rgba(0,0,0,0.5);
  transition: border-color 0.2s var(--ease);
}
.card:hover { border-color: var(--border); }

.card-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0 0 14px;
  font-weight: 600;
}

.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.card-head .card-label { margin: 0; }
.card-head-sub { font-size: 12px; color: var(--text-faint); }

/* ===================== JOURNEY BAR ===================== */
.journey-card {
  background: linear-gradient(135deg, rgba(255,90,54,0.07), rgba(110,231,183,0.05));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 22px 18px;
}
.journey-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.journey-label {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.journey-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--green);
  font-weight: 700;
}
.journey-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-hi);
  overflow: visible;
}
.journey-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--orange-soft) 60%, var(--green));
  transition: width 0.7s var(--ease);
}
.journey-marker {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.7s var(--ease);
  box-shadow: 0 0 0 4px rgba(110,231,183,0.15);
}
.journey-marker-value {
  position: absolute;
  top: -26px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-hi-2);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.journey-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
}
.journey-ends i { font-style: normal; color: var(--text-faint); font-family: 'Inter', sans-serif; margin-left: 4px; }

/* ===================== DASHBOARD GRID ===================== */
.grid-top {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .grid-top { grid-template-columns: 1fr; }
}

/* Gauge */
.gauge-card { display: flex; flex-direction: column; align-items: center; }
.gauge-wrap { position: relative; width: 100%; max-width: 230px; }
.gauge-svg { width: 100%; filter: drop-shadow(0 4px 16px rgba(0,0,0,0.35)); }
.gauge-track { fill: none; stroke: var(--surface-hi); stroke-width: 13; stroke-linecap: round; }
.gauge-arc { fill: none; stroke: url(#gaugeGradient); stroke-width: 13; stroke-linecap: round; stroke-dasharray: 251; stroke-dashoffset: 251; transition: stroke-dashoffset 0.6s var(--ease); filter: url(#gaugeGlow); }
.gauge-ticks line { stroke: var(--border); stroke-width: 1.5; }
.gauge-needle { stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; transform-origin: 100px 110px; transition: transform 0.6s var(--ease); }
.gauge-hub { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.gauge-hub-inner { fill: var(--text); }
.gauge-readout { text-align: center; margin-top: -6px; }
.gauge-value { font-family: 'JetBrains Mono', monospace; font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.gauge-unit { font-size: 11px; color: var(--text-dim); display: block; text-transform: uppercase; letter-spacing: 0.06em; }
.gauge-zone-labels { display: flex; justify-content: space-between; margin-top: -4px; padding: 0 4px; }
.zone-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.zone-label.zone-low { color: #B0654F; }
.zone-label.zone-high { color: #5FAE8A; }
.gauge-legend { display: flex; gap: 18px; margin-top: 14px; font-size: 12px; color: var(--text-dim); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-item b { color: var(--text); font-family: 'JetBrains Mono', monospace; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-in { background: var(--green); box-shadow: 0 0 8px rgba(110,231,183,0.6); }
.dot-out { background: var(--orange); box-shadow: 0 0 8px rgba(255,90,54,0.6); }

/* Streak */
.streak-card { display: flex; flex-direction: column; }
.streak-dots { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.streak-dot {
  width: 28px; height: 28px; border-radius: 8px; background: var(--surface-hi);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: var(--text-faint);
  transition: all 0.2s var(--ease);
}
.streak-dot.done {
  background: linear-gradient(135deg, #85F0C4, var(--green));
  border-color: var(--green); color: #05130E;
  box-shadow: 0 4px 14px -4px rgba(110,231,183,0.5);
}
.streak-dot.today { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,90,54,0.12); }
.streak-count { font-family: 'JetBrains Mono', monospace; font-size: 22px; margin: 0; font-weight: 700; }
.streak-sub { color: var(--text-dim); font-size: 12px; margin: 5px 0 0; line-height: 1.4; }

/* ETA */
.eta-card { display: flex; flex-direction: column; }
.eta-big { font-family: 'Space Grotesk', sans-serif; font-size: 21px; font-weight: 700; margin: 0; color: var(--green); letter-spacing: -0.01em; }
.eta-sub { color: var(--text-dim); font-size: 12px; margin: 7px 0 0; line-height: 1.45; }

/* Weight chart */
.weight-chart-card { padding-bottom: 14px; }

/* PR list */
.pr-list, .data-list, .seance-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pr-list li, .data-list li, .seance-list li {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-hi); border: 1px solid transparent; border-radius: 10px; padding: 11px 13px; font-size: 13px;
  transition: border-color 0.15s var(--ease);
}
.pr-list li:hover, .data-list li:hover, .seance-list li:hover { border-color: var(--border); }
.pr-list li { border-left: 2px solid var(--orange); }
.pr-list li b { color: var(--orange); font-family: 'JetBrains Mono', monospace; }
.empty-row { color: var(--text-faint); justify-content: flex-start !important; border-left: none !important; font-style: italic; }

/* ===================== SÉANCE ===================== */
.seance-type-toggle { display: flex; gap: 8px; margin-bottom: 18px; }
.toggle-btn {
  flex: 1;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 11px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  transition: all 0.18s var(--ease);
}
.toggle-btn.is-active {
  background: linear-gradient(135deg, #FF7A56, var(--orange));
  color: #1A0900; border-color: var(--orange);
  box-shadow: 0 6px 18px -6px rgba(255,90,54,0.5);
}

.seance-form { display: flex; flex-direction: column; gap: 14px; }

.calc-preview {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-hi); border-radius: 10px; padding: 12px 14px;
  font-size: 13px; color: var(--text-dim);
}
.calc-preview b { color: var(--green); font-family: 'JetBrains Mono', monospace; font-size: 16px; }

.series-list { display: flex; flex-direction: column; gap: 10px; }
.serie-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 6px; align-items: center; }
.serie-row select, .serie-row input {
  background: var(--surface-hi); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; color: var(--text); font-size: 13px; width: 100%; font-family: inherit;
}
.serie-remove { background: none; border: none; color: var(--red); cursor: pointer; font-size: 16px; }

/* ===================== FORMS: poids / repas ===================== */
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input {
  flex: 1; background: var(--surface-hi); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--text); font-size: 15px; font-family: inherit;
}
.inline-form-stack { display: flex; flex-direction: column; gap: 10px; }
.inline-form-stack input[type="text"] {
  background: var(--surface-hi); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--text); font-size: 14px; font-family: inherit;
}
.unit-suffix { color: var(--text-dim); font-size: 13px; }

.total-row { color: var(--text-dim); font-size: 13px; margin: 12px 0 0; text-align: right; }
.total-row b { color: var(--text); font-family: 'JetBrains Mono', monospace; }

/* ===================== HISTORIQUE / HEATMAP ===================== */
.heatmap { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.hm-week { display: flex; flex-direction: column; gap: 4px; }
.hm-cell { width: 100%; aspect-ratio: 1; border-radius: 4px; background: var(--surface-hi); transition: transform 0.12s var(--ease); }
.hm-cell:hover { transform: scale(1.25); }
.hm-0 { background: var(--surface-hi); }
.hm-1 { background: #2C5347; }
.hm-2 { background: #3E8F6E; }
.hm-3 { background: var(--green); box-shadow: 0 0 6px rgba(110,231,183,0.4); }
.heatmap-legend { display: flex; align-items: center; gap: 6px; margin-top: 14px; font-size: 11px; color: var(--text-dim); }
.heatmap-legend .dot { width: 10px; height: 10px; border-radius: 3px; }

/* ===================== PROFIL ===================== */
.save-confirm {
  color: var(--green); font-size: 13px; text-align: center; margin: 10px 0 0;
  animation: viewIn 0.3s var(--ease);
}

.api-key-box {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--green);
  word-break: break-all;
  user-select: all;
}

/* ===================== NUTRITION ===================== */
.nutrition-summary { display: flex; gap: 28px; flex-wrap: wrap; }
.nutrition-big { font-family: 'JetBrains Mono', monospace; font-size: 30px; font-weight: 700; margin-right: 6px; }
.nutrition-unit { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.nutrition-source { color: var(--text-dim); font-size: 12px; margin: 10px 0 0; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 480px) {
  .topbar { padding: 12px 14px; }
  .views { padding: 14px; }
  .serie-row { grid-template-columns: 1fr 1fr; }
}
