@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #07071a;
  --s1: #0e0e26;
  --s2: #14142e;
  --s3: #1c1c3a;
  --border: rgba(255,255,255,0.08);
  --primary: #7c6fec;
  --primary-dim: rgba(124,111,236,0.15);
  --success: #00d4a3;
  --success-dim: rgba(0,212,163,0.12);
  --warning: #ff9f43;
  --warning-dim: rgba(255,159,67,0.12);
  --danger: #ff6b6b;
  --danger-dim: rgba(255,107,107,0.12);
  --text: #e4e4f4;
  --text2: #9898bc;
  --text3: #5c5c7c;
  --radius: 18px;
  --radius-sm: 10px;
  --nav-h: 60px;
  --header-h: 54px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

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

/*
 * MOBILE-FIRST LAYOUT — compatible iOS Safari + Chrome
 * PAS de position:fixed sur html/body (casse iOS Safari)
 * html/body = hauteur 100% + overflow hidden
 * header/nav = position:fixed au viewport, centrés via left/right calc
 * #app = seul conteneur scrollable, padding pour header/nav
 */
html {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  height: 100%;
  height: 100dvh;         /* dynamic viewport height iOS Safari */
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  position: relative;     /* PAS fixed — c'est la clé du fix iOS */
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ─── HEADER ─────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 20px;
  padding-right: 20px;
  padding-bottom: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  background: rgba(7,7,26,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  /* Centré sur desktop — même max-width que body */
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.app-header h1 {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-date {
  font-size: 0.72rem;
  color: var(--text2);
  font-weight: 600;
}

/* ─── BOTTOM NAV ─────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: rgba(14,14,38,0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  /* Centré sur desktop */
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text3);
  border: none;
  background: none;
  padding: 0 4px;
  transition: color 0.2s;
  position: relative;
  min-height: 44px;
  touch-action: manipulation;
}

.nav-item.active { color: var(--primary); }

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 2px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

.nav-icon { font-size: 1.25rem; line-height: 1; transition: transform 0.2s; }
.nav-item.active .nav-icon { transform: scale(1.1); }
.nav-label { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }

/* ─── SCROLL CONTAINER ───────────────────────────────── */
#app {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  /* padding pour ne pas passer derrière header/nav */
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(var(--nav-h) + var(--safe-bot));
}

/* ─── PAGES ──────────────────────────────────────────── */
.page {
  display: none;
  padding: 14px 14px 20px;
  min-height: 100%;
  animation: fadeUp 0.22s ease;
}
.page.active { display: block; }

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

/* ─── CARDS ──────────────────────────────────────────── */
.card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.card-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.card-title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.card-sub   { font-size: 0.72rem; color: var(--text2); margin-top: 2px; }

.quick-date-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.quick-date-btn.active {
  background: var(--primary-dim);
  border-color: rgba(124,111,236,0.35);
  color: var(--primary);
}

/* ─── READINESS RING ─────────────────────────────────── */
.readiness-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 14px;
}

.ring-container {
  position: relative;
  width: 150px; height: 150px;
  margin-bottom: 10px;
}

.ring-svg { transform: rotate(-90deg); width: 150px; height: 150px; }
.ring-bg   { fill: none; stroke: var(--s3); stroke-width: 10; }
.ring-fill { fill: none; stroke-width: 10; stroke-linecap: round;
             transition: stroke-dashoffset 1s cubic-bezier(0.4,0,0.2,1); }

.ring-center {
  position: absolute;
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  text-align: center;
}

.ring-score {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ring-label {
  font-size: 0.62rem;
  color: var(--text2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.readiness-status {
  font-size: 0.82rem;
  color: var(--text2);
  font-weight: 500;
  text-align: center;
}

/* ─── METRICS GRID ───────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px;
  min-width: 0;
}

.metric-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-label { font-size: 0.7rem; color: var(--text2); margin-top: 4px; font-weight: 600; }
.metric-sub   { font-size: 0.65rem; color: var(--text3); margin-top: 3px; }

/* ─── GOALS ──────────────────────────────────────────── */
.goal-item { margin-bottom: 14px; }
.goal-item:last-child { margin-bottom: 0; }

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
  gap: 8px;
}

.goal-name  { font-size: 0.8rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.goal-value { font-size: 0.72rem; color: var(--text2); white-space: nowrap; }

.progress-bar { height: 7px; background: var(--s3); border-radius: 10px; overflow: hidden; }
.progress-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 1s cubic-bezier(0.4,0,0.2,1);
}

/* ─── FORMS ──────────────────────────────────────────── */
.form-section { margin-bottom: 20px; }

.section-title {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 12px;
  padding-left: 2px;
}

.form-grid     { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.one   { grid-template-columns: 1fr; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text2);
  padding-left: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select,
.field textarea {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 12px;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  font-family: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.field input::placeholder,
.field textarea::placeholder { color: var(--text3); }
.field textarea { resize: vertical; min-height: 80px; }

/* ─── SLIDERS ────────────────────────────────────────── */
.slider-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.slider-header { display: flex; justify-content: space-between; align-items: center; }
.slider-label  { font-size: 0.7rem; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; }
.slider-value  { font-size: 0.9rem; font-weight: 800; color: var(--primary); min-width: 28px; text-align: right; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 10px;
  background: var(--s3);
  outline: none;
  width: 100%;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 2px 10px rgba(124,111,236,0.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
}

/* ─── BUTTONS ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 13px;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
  min-height: 48px;
  touch-action: manipulation;
  -webkit-appearance: none;
}

.btn-primary  { background: linear-gradient(135deg, #7c6fec, #9c8ff8); color: white; box-shadow: 0 4px 20px rgba(124,111,236,0.35); }
.btn-primary:active  { transform: scale(0.97); }
.btn-success  { background: linear-gradient(135deg, var(--success), #00b88a); color: white; box-shadow: 0 4px 20px rgba(0,212,163,0.3); }
.btn-success:active  { transform: scale(0.97); }
.btn-danger   { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(255,107,107,0.25); }
.btn-ghost    { background: var(--s2); color: var(--text2); border: 1px solid var(--border); }
.btn-full     { width: 100%; }
.btn-sm       { padding: 9px 14px; font-size: 0.78rem; border-radius: 9px; min-height: 40px; }

/* ─── SESSION TYPE CARDS ──────────────────────────────── */
.session-types { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.session-type-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  touch-action: manipulation;
  min-width: 0;
}
.session-type-card:active { transform: scale(0.96); }
.type-name { font-size: 0.82rem; font-weight: 700; color: var(--text); }

/* ─── ACTIVE SESSION ─────────────────────────────────── */
.session-header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.session-timer {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--success);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* ─── EXERCISE CARD ──────────────────────────────────── */
.exercise-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.exercise-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.exercise-emoji {
  width: 44px; height: 44px;
  background: var(--s2);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.exercise-name   { font-size: 0.88rem; font-weight: 800; color: var(--text); }
.exercise-muscles { font-size: 0.67rem; color: var(--text2); margin-top: 3px; line-height: 1.4; }

.exercise-instruction {
  font-size: 0.76rem;
  color: var(--text2);
  line-height: 1.55;
  background: var(--s2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-left: 3px solid var(--primary);
  word-break: break-word;
}

.exercise-hint {
  font-size: 0.72rem;
  color: var(--text);
  line-height: 1.45;
  background: rgba(124,111,236,0.10);
  border: 1px solid rgba(124,111,236,0.22);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

/* ─── EXERCISE ILLUSTRATION ──────────────────────────── */
.exercise-illustration {
  width: 100%;
  border-radius: 12px;
  margin-bottom: 14px;
  background: #0d0d24;
  border: 1px solid var(--border);
  line-height: 0;
  overflow: hidden;
}

.exercise-illustration img {
  width: 100%;
  height: auto;
  max-height: 150px;
  display: block;
  object-fit: contain;
}

/* ─── SETS TABLE ──────────────────────────────────────── */
.sets-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sets-table-wrap::-webkit-scrollbar { display: none; }

.sets-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 200px;
}

.sets-table th {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 6px 4px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}

.sets-table td { padding: 4px 3px; }

.sets-table input {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 4px;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  width: 100%;
  min-width: 0;
  font-family: inherit;
  text-align: center;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.sets-table input:focus { border-color: var(--primary); }

.set-number {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text3);
  text-align: center;
  padding: 6px 4px;
  white-space: nowrap;
  width: 32px;
}

.add-set-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 11px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 9px;
  color: var(--text3);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
  transition: all 0.15s;
  min-height: 44px;
  touch-action: manipulation;
}
.add-set-btn:active { border-color: var(--primary); color: var(--primary); }

/* ─── HISTORY ────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 14px;
  min-width: 0;
}

.history-date { font-size: 0.72rem; font-weight: 800; color: var(--text2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }

.history-metrics { display: flex; flex-wrap: wrap; gap: 6px; }

.history-pill {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 0.72rem;
  color: var(--text);
  font-weight: 600;
}

.history-notes { font-size: 0.75rem; color: var(--text2); margin-top: 8px; line-height: 1.5; font-style: italic; }

/* ─── LIBRARY ────────────────────────────────────────── */
.library-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.library-icon {
  font-size: 1.7rem;
  flex-shrink: 0;
  width: 50px; height: 50px;
  background: var(--s2);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.library-body { flex: 1; min-width: 0; }
.library-name { font-size: 0.88rem; font-weight: 800; color: var(--text); margin-bottom: 5px; }
.library-why  { font-size: 0.75rem; color: var(--text2); line-height: 1.5; margin-bottom: 8px; }
.library-instruction {
  font-size: 0.72rem; color: var(--text2); line-height: 1.5;
  background: var(--s2); border-radius: 8px; padding: 8px 10px;
  border-left: 3px solid var(--success);
}

/* ─── PILLS ──────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.67rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.pill-purple { background: var(--primary-dim); color: var(--primary); }
.pill-green  { background: var(--success-dim); color: var(--success); }
.pill-orange { background: var(--warning-dim); color: var(--warning); }
.pill-red    { background: var(--danger-dim);  color: var(--danger);  }

/* ─── TABS ───────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--s2);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  padding: 10px;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 700;
  border: none;
  background: none;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  min-height: 44px;
  touch-action: manipulation;
}
.tab.active { background: var(--s3); color: var(--text); }

/* ─── TOAST ──────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bot) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--s2);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 13px;
  padding: 12px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 300;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 40px);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── BACK BUTTON ────────────────────────────────────── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text2);
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  padding: 9px 14px;
  font-family: inherit;
  margin-bottom: 14px;
  transition: all 0.15s;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-appearance: none;
}
.back-btn:active { opacity: 0.7; }

/* ─── EMPTY STATE ────────────────────────────────────── */
.empty-state { text-align: center; padding: 36px 20px; color: var(--text3); }
.empty-icon  { font-size: 2.5rem; display: block; margin-bottom: 12px; }

/* ─── MISC ───────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-h2 { font-size: 1rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Scrollbar minimaliste */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--s3); border-radius: 2px; }

/* ─── BTN ICON ───────────────────────────────────────── */
.btn-icon {
  width: 34px; height: 34px;
  border: none;
  background: var(--s2);
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  touch-action: manipulation;
}
.btn-icon:active { transform: scale(0.92); }

/* ─── SESSIONS SECTIONS ──────────────────────────────── */
.sessions-section { margin-bottom: 22px; }

/* ─── TODAY PLAN CARD ────────────────────────────────── */
.today-plan-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 4px;
}

.today-plan-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.today-plan-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.today-plan-info { flex: 1; min-width: 0; }
.today-plan-title { font-size: 0.68rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; }
.today-plan-type  { font-size: 1rem; font-weight: 900; color: var(--text); margin-top: 2px; }

.today-plan-details {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--text2);
  margin-bottom: 6px;
}

.today-plan-exercises {
  font-size: 0.72rem;
  color: var(--text3);
  margin-bottom: 14px;
  line-height: 1.5;
}

.today-plan-empty {
  background: var(--s1);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.82rem;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── WEEK CALENDAR STRIP ────────────────────────────── */
.week-strip {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.week-strip::-webkit-scrollbar { display: none; }

.week-day {
  flex: 1;
  min-width: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 12px;
  cursor: pointer;
  border: 1.5px solid transparent;
  background: var(--s1);
  transition: all 0.15s;
  touch-action: manipulation;
}
.week-day:active { transform: scale(0.93); }
.week-day.today  { border-color: var(--primary); background: var(--primary-dim); }
.week-day.selected { border-color: var(--success); background: var(--success-dim); }

.week-day-name {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.week-day.today .week-day-name { color: var(--primary); }

.week-day-num {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}

.week-day-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.week-day-dot.empty   { background: var(--s3); }
.week-day-dot.done    {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.5rem;
  color: white;
  font-weight: 900;
}

/* ─── DAY DETAIL ─────────────────────────────────────── */
.day-detail-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  animation: fadeUp 0.18s ease;
}

.day-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.day-detail-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text);
}

.day-detail-empty {
  font-size: 0.8rem;
  color: var(--text3);
  text-align: center;
  padding: 12px 0;
}

.day-detail-session {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--s2);
  margin-bottom: 8px;
  border-left: 3px solid var(--primary);
}
.day-detail-session:last-child { margin-bottom: 0; }

.day-detail-session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.day-detail-exercises {
  font-size: 0.72rem;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 6px;
}

.day-detail-notes {
  font-size: 0.72rem;
  color: var(--text3);
  font-style: italic;
  margin-bottom: 8px;
}

.day-detail-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ─── OVERLAY (goals editor + plan editor) ───────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.overlay-panel {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.28s cubic-bezier(0.34,1.2,0.64,1);
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0.6; }
  to   { transform: translateY(0);    opacity: 1; }
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.overlay-title {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
}

.overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  -webkit-overflow-scrolling: touch;
}

.overlay-footer {
  display: flex;
  gap: 10px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.overlay-footer .btn { flex: 1; }

/* ─── GOALS EDITOR ───────────────────────────────────── */
.goal-editor-row {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
}

.goal-editor-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ge-label {
  flex: 1;
  background: var(--s3);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  outline: none;
  font-family: inherit;
  width: 100%;
}
.ge-label:focus { border-color: var(--primary); }

.ge-delete {
  width: 36px; height: 36px;
  border: none;
  background: var(--danger-dim);
  color: var(--danger);
  border-radius: 9px;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
.ge-delete:active { transform: scale(0.9); }

.goal-editor-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.goal-editor-fields:last-child { margin-bottom: 0; }

.ge-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ge-field label {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ge-field input,
.ge-field select {
  background: var(--s3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 8px;
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
  font-family: inherit;
  width: 100%;
  -webkit-appearance: none;
}
.ge-field input:focus,
.ge-field select:focus { border-color: var(--primary); }

/* ─── PLAN EDITOR ────────────────────────────────────── */
.plan-types-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.plan-type-option {
  background: var(--s2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text2);
  transition: all 0.15s;
  touch-action: manipulation;
}
.plan-type-option:active { transform: scale(0.96); }
.plan-type-option.selected {
  border-color: var(--primary);
  background: var(--primary-dim);
  color: var(--text);
}


/* ══════════════════════════════════════════════════════════
   MODULE NUTRITION
═══════════════════════════════════════════════════════════ */

/* ─── Date bar ─────────────────────────────────────────── */
.nutrition-date-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.nutri-date-input {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.82rem;
  color: var(--text);
  outline: none;
  font-family: inherit;
  margin-left: auto;
  -webkit-appearance: none;
  color-scheme: dark;
}
.nutri-date-input:focus { border-color: var(--primary); }

/* ─── Summary card / macro bars ────────────────────────── */
.nutri-summary-card { margin-bottom: 14px; }

.nutri-bar-row { margin-bottom: 11px; }
.nutri-bar-row:last-child { margin-bottom: 0; }

.nutri-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 5px;
}

.nutri-bar-vals { font-weight: 600; color: var(--text3); }
.nutri-bar-vals.over { color: #ff6b6b; font-weight: 800; }
.nutri-unit { font-size: 0.7rem; opacity: 0.75; margin-left: 1px; }

.nutri-bar-track {
  height: 8px;
  background: var(--s3);
  border-radius: 99px;
  overflow: hidden;
}
.nutri-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  min-width: 4px;
}

/* ─── Meal cards ────────────────────────────────────────── */
.nutri-meal-card {
  margin-bottom: 10px;
  padding: 12px 14px;
}

.nutri-meal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.nutri-meal-name {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 2px;
}

.nutri-meal-time {
  font-size: 0.72rem;
  color: var(--text3);
}

.nutri-meal-macros {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Macro pills */
.nutri-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.nutri-pill.cal   { background: rgba(255,107,107,0.15); color: #ff6b6b; }
.nutri-pill.prot  { background: rgba(124,111,236,0.15); color: #7c6fec; }
.nutri-pill.carb  { background: rgba(255,159,67,0.15);  color: #ff9f43; }
.nutri-pill.fat   { background: rgba(254,202,87,0.15);  color: #d4a800; }
.nutri-pill.sugar { background: rgba(255,99,72,0.13);   color: #ff6348; }

/* Fav / delete icon buttons on meals */
.nutri-fav-btn, .nutri-del-btn {
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  touch-action: manipulation;
  opacity: 0.5;
}
.nutri-fav-btn:hover, .nutri-del-btn:hover { background: var(--s3); opacity: 1; }
.nutri-fav-btn.active { opacity: 1; }
.nutri-del-btn:hover  { background: var(--danger-dim); color: var(--danger); }

/* ─── Empty state ───────────────────────────────────────── */
.nutri-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text3);
}
.nutri-empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.nutri-empty-text { font-size: 0.95rem; font-weight: 700; margin-bottom: 4px; }
.nutri-empty-sub  { font-size: 0.8rem; opacity: 0.7; }

/* ─── FAB (floating action button) ─────────────────────── */
.nutri-fab {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 12px);
  right: 18px;
  width: 54px;
  height: 54px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,212,163,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
  z-index: 50;
}
.nutri-fab:active { transform: scale(0.91); box-shadow: 0 2px 8px rgba(0,212,163,0.3); }

/* ─── Add meal overlay ──────────────────────────────────── */
.overlay-panel-tall {
  max-height: 90vh;
  overflow-y: auto;
}

.meal-input-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.meal-input-tab {
  flex: 1;
  background: var(--s2);
  border: 1.5px solid var(--border);
  color: var(--text2);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  touch-action: manipulation;
}
.meal-input-tab.active {
  border-color: var(--primary);
  background: var(--primary-dim);
  color: var(--text);
}

/* Photo upload zone */
.photo-upload-zone {
  width: 100%;
  min-height: 130px;
  background: var(--s2);
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: border-color 0.15s;
}
.photo-upload-zone:hover { border-color: var(--primary); }
.photo-preview-empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px;
  color: var(--text3);
}

/* ─── Analysis result card ──────────────────────────────── */
.nutri-result-card {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-top: 4px;
}
.nutri-result-name {
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text);
}
.nutri-result-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.nutri-result-macro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.macro-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.macro-val.prot  { color: #7c6fec; }
.macro-val.carb  { color: #ff9f43; }
.macro-val.fat   { color: #d4a800; }
.macro-val.sugar { color: #ff6348; }

.macro-lbl {
  font-size: 0.62rem;
  color: var(--text3);
  font-weight: 600;
  margin-top: 2px;
}

/* Favorite checkbox */
.nutri-fav-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  color: var(--text2);
  cursor: pointer;
  padding-top: 4px;
}
.nutri-fav-check input[type=checkbox] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ─── Nutrition targets overlay ─────────────────────────── */
.form-grid {
  display: grid;
  gap: 12px;
}

/* page visibility for nutrition */
#page-nutrition { display: none; }
#page-nutrition.active { display: block; }

/* ─── Photo source buttons ──────────────────────────────── */
.photo-source-btns {
  display: flex;
  gap: 10px;
  margin-bottom: 2px;
}
.photo-source-btn {
  flex: 1;
  justify-content: center;
  font-size: 0.85rem;
  padding: 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-weight: 700;
  transition: all 0.15s;
}
.photo-source-btn:active {
  transform: scale(0.96);
  border-color: var(--primary);
  background: var(--primary-dim);
}
