:root {
  --bg: #14161b;
  --surface: #1c1f26;
  --surface-2: #262a33;
  --border: #333844;
  --text: #eceef1;
  --text-dim: #9aa0ac;
  --accent: #6b8f8c;
  --accent-strong: #8fb4b0;
  --danger: #c47a6a;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* L'attribut hidden doit gagner sur les display: flex des composants. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px 14px;
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar-sub {
  font-size: 13px;
  color: var(--text-dim);
}

#app {
  flex: 1;
  padding: 20px 20px 12px;
  overflow-y: auto;
}

.view { display: none; }
.view.active { display: block; }

.view-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 4px 0 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.info-card {
  margin-bottom: 16px;
}

.info-card summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}

.info-card summary::-webkit-details-marker { display: none; }

.info-card summary::before {
  content: "+ ";
  color: var(--accent-strong);
}

.info-card[open] summary::before {
  content: "- ";
}

.info-list {
  margin: 12px 0 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}

.info-list li { margin-bottom: 8px; }
.info-list li:last-child { margin-bottom: 0; }
.info-list strong { color: var(--text); }

.info-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0 0;
}

.program-card { margin-bottom: 20px; }

.program-title {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.program-block {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 0;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.program-block:first-child { border-top: none; }

.program-block-label::after {
  content: " ›";
  color: var(--accent-strong);
}

.program-block-label {
  font-size: 13px;
  color: var(--text-dim);
}

.program-block-value {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

.cardio-row .program-block-label::after { content: none; }

.exercise-badge {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.timer-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0 16px;
}

.gauge-wrap {
  max-width: 240px;
  margin: 0 auto 28px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.gauge-track {
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-strong);
  transition: width 0.4s ease;
}

.gauge-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 38px;
  text-align: right;
}

.timer-ring {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.6s ease, border-color 0.4s ease, background 0.4s ease;
}

.timer-ring.phase-hold {
  border-color: var(--accent-strong);
  transform: scale(1.06);
  background: var(--surface-2);
}

.timer-ring.phase-rest {
  border-color: var(--border);
  transform: scale(0.94);
}

.timer-ring.phase-inhale {
  border-color: var(--accent-strong);
  background: var(--surface-2);
  transform: scale(1.15);
  transition: transform 2.8s ease-in-out, border-color 2.8s ease-in-out, background 2.8s ease-in-out;
}

.timer-ring.phase-exhale {
  border-color: var(--border);
  transform: scale(0.85);
  transition: transform 2.8s ease-in-out, border-color 2.8s ease-in-out, background 2.8s ease-in-out;
}

.timer-phase {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  max-width: 200px;
  color: var(--text-dim);
}

.timer-count {
  font-size: 56px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.timer-meta {
  font-size: 13px;
  color: var(--text-dim);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  max-width: 320px;
  margin: 0 auto;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--accent);
  color: #0e1210;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-small {
  padding: 8px 14px;
  font-size: 14px;
}

.done-note {
  text-align: center;
  color: var(--accent-strong);
  font-size: 14px;
  margin-top: 20px;
}

.journal-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.field-label {
  font-size: 14px;
  color: var(--text-dim);
}

.num-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  width: 100%;
}

.toggle-group, .scale-group {
  display: flex;
  gap: 8px;
}

.toggle-btn, .scale-btn {
  flex: 1;
  padding: 12px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

.toggle-btn.selected, .scale-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #0e1210;
  font-weight: 600;
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}

.save-note {
  text-align: center;
  color: var(--accent-strong);
  font-size: 13px;
  margin: 0;
}

.streak-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 22px;
}

.streak-value {
  font-size: 40px;
  font-weight: 300;
  line-height: 1;
}

.streak-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  gap: 3px;
  position: relative;
}

.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--accent-strong); color: var(--text); }

.cal-dots { display: flex; gap: 3px; }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: var(--border);
}

.dot-done { background: var(--accent-strong); }
.dot-journal { background: var(--danger); }

.cal-legend {
  display: flex;
  gap: 18px;
  justify-content: center;
  font-size: 12px;
  color: var(--text-dim);
}

.legend-item { display: flex; align-items: center; gap: 6px; }

.tabbar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
}

.tab.active { color: var(--text); }
.tab-icon { font-size: 16px; }

/* ---- v2 : programme, bilan, fiches ---- */

.program-goal,
.program-foot {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.program-foot { margin: 10px 0 0; }

.checkin-card {
  border-color: var(--accent-strong);
  margin-bottom: 16px;
}

.checkin-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
}

.checkin-text {
  font-size: 14px;
  color: var(--text-dim);
  margin: 0 0 12px;
}

.notice {
  font-size: 14px;
  color: var(--accent-strong);
  margin: 0 0 16px;
}

.cardio-card { margin-bottom: 24px; }

.cardio-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.cardio-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 10px 0 0;
}

.figure-wrap {
  max-width: 260px;
  margin: 0 auto 4px;
}

.figure {
  display: block;
  width: 100%;
  height: auto;
}

.fig-body, .fig-arm {
  fill: none;
  stroke: var(--text);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fig-body { stroke-width: 7; }
.fig-arm { stroke-width: 5; }
.fig-head { fill: var(--text); }

.fig-prop {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
  stroke-linecap: round;
}

.fig-dot { fill: var(--accent-strong); }
.fig-halo { fill: var(--accent-strong); opacity: 0.25; }

.cue {
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-dim);
  max-width: 300px;
  margin: 0 auto 4px;
}

.ex-card { margin-bottom: 16px; }

.ex-card .figure {
  max-width: 240px;
  margin: 0 auto 8px;
}

.ex-name {
  font-size: 16px;
  margin: 0 0 10px;
}

.ex-steps, .ex-avoid {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.5;
}

.ex-steps li, .ex-avoid li { margin-bottom: 6px; }

.ex-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
  margin: 14px 0 6px;
}

.ex-text {
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.info-list a { color: var(--accent-strong); }

.drop-report {
  text-align: center;
  margin-top: 28px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}

.drop-confirm p {
  font-size: 14px;
  color: var(--text);
  margin: 8px 0 12px;
}

.drop-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Pendant une séance, seul l'exercice en cours reste à l'écran. */
.in-session .checkin-card,
.in-session .notice,
.in-session .program-card,
.in-session .cardio-card,
.in-session .drop-report { display: none; }

/* ---- Notes et historique ---- */

.text-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  width: 100%;
  resize: vertical;
}

.history-title { margin-top: 32px; }

.export-card { margin-bottom: 16px; }

.export-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 0 0 12px;
}

.export-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.export-card .save-note { margin-top: 10px; text-align: left; }

.history-item { margin-bottom: 10px; padding: 12px 14px; }

.history-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
  margin: 0 0 4px;
}

.history-scores {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

.history-notes {
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-empty {
  font-size: 14px;
  color: var(--text-dim);
}

/* ---- Animation des dessins ---- */

.fig-legend {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.legend-dot {
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 0 5px rgba(143, 180, 176, 0.25);
}

.fig-belly {
  fill: var(--text);
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scaleY(0.35);
  transition: transform 2.8s ease-in-out;
}

.fig-dot, .fig-halo {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.6s ease, opacity 0.6s ease;
}

.fig-leg {
  transform-box: view-box;
  transform-origin: 100px 82px;
}

.fig-arrow {
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fig-lift, .fig-drop {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* États pilotés par le minuteur pendant la séance */
.s-contract .fig-dot { transform: scale(var(--dot-scale, 0.55)); }
.s-contract .fig-halo { transform: scale(0.6); opacity: 0.6; }
.s-contract .fig-lift { opacity: 1; animation: nudge 1s ease-in-out infinite; }
.s-descend .fig-lift { opacity: 0; animation: none; }
.s-descend .fig-drop { opacity: 1; animation: nudge 1.4s ease-in-out infinite; }
.s-release .fig-dot { transform: scale(1.25); }
.s-release .fig-halo { transform: scale(1.5); opacity: 0.12; }
.s-release .fig-drop { opacity: 1; animation: nudge 1.4s ease-in-out infinite; }
.s-inhale .fig-belly { transform: scaleY(1); }

/* Démonstrations en boucle (onglet Exercices et étirements en séance) */
.demo-breath .fig-belly,
.demo-reverse .fig-belly { animation: belly 6s ease-in-out infinite; }
.demo-breath .fig-dot,
.demo-reverse .fig-dot { animation: dot-open 6s ease-in-out infinite; }
.demo-reverse .fig-drop { animation: show-mid 6s ease-in-out infinite; }

.demo-hold .fig-dot { animation: dot-hold 8s ease-in-out infinite; }
.demo-hold .fig-halo { animation: halo-hold 8s ease-in-out infinite; }
.demo-hold .fig-lift { animation: show-hold 8s ease-in-out infinite; }
.demo-hold .fig-drop { animation: show-release 8s ease-in-out infinite; }

.demo-elevator .fig-dot { animation: dot-steps 14s ease-in-out infinite; }
.demo-elevator .fig-lift { animation: show-up 14s linear infinite; }
.demo-elevator .fig-drop { animation: show-down 14s linear infinite; }

.demo-butterfly .fig-leg-l { animation: knee-l 6s ease-in-out infinite; }
.demo-butterfly .fig-leg-r { animation: knee-r 6s ease-in-out infinite; }

@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes belly {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

@keyframes dot-open {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

@keyframes show-mid {
  0%, 15%, 85%, 100% { opacity: 0; }
  30%, 70% { opacity: 1; }
}

@keyframes dot-hold {
  0%, 5% { transform: scale(1); }
  12%, 45% { transform: scale(0.55); }
  55%, 100% { transform: scale(1.2); }
}

@keyframes halo-hold {
  0%, 5% { transform: scale(1); opacity: 0.25; }
  12%, 45% { transform: scale(0.6); opacity: 0.6; }
  55%, 100% { transform: scale(1.4); opacity: 0.12; }
}

@keyframes show-hold {
  0%, 6% { opacity: 0; }
  12%, 45% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes show-release {
  0%, 50% { opacity: 0; }
  58%, 95% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes dot-steps {
  0%, 8% { transform: scale(1); }
  12%, 20% { transform: scale(0.85); }
  24%, 32% { transform: scale(0.7); }
  36%, 44% { transform: scale(0.55); }
  50%, 64% { transform: scale(0.7); }
  70%, 84% { transform: scale(0.85); }
  90%, 100% { transform: scale(1); }
}

@keyframes show-up {
  0%, 8% { opacity: 0; }
  10%, 44% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

@keyframes show-down {
  0%, 46% { opacity: 0; }
  48%, 86% { opacity: 1; }
  88%, 100% { opacity: 0; }
}

@keyframes knee-l {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-11deg); }
}

@keyframes knee-r {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(11deg); }
}

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

/* ---- Activité et bilan ---- */

.optional-scores {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.optional-note {
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.checkin-none {
  width: 100%;
  margin-top: 8px;
}
