:root {
  --bg: #101418;
  --bg-card: #1a2027;
  --bg-card2: #222a33;
  --fg: #e8edf2;
  --muted: #8a97a5;
  --accent: #4fc3f7;
  --accent-fg: #06283a;
  --ok: #58d68d;
  --danger: #ef5350;
  --border: #2a333d;
  --app-top-inset: 0px;
  --safe-bottom: 0px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f8;
    --bg-card: #ffffff;
    --bg-card2: #eef1f4;
    --fg: #1a2027;
    --muted: #5d6b79;
    --accent: #0277bd;
    --accent-fg: #ffffff;
    --border: #d8dee5;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* altfel display:flex pe clase bate atributul hidden */
html { height: 100%; }
/* iOS 26 standalone: pagina mai scurtă decât ecranul (WebKit 301108) */
@media (display-mode: standalone) {
  html { min-height: min(100lvh, calc(100% + env(safe-area-inset-top))); }
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* Header: insetul de sus stă ÎN header, pe culoarea lui */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-top: max(6px, calc(env(safe-area-inset-top) - 10px));
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
}
h1 { font-size: 20px; margin: 0; letter-spacing: .5px; }
.session-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
  font-size: 18px;
}

main {
  padding: 16px 16px calc(120px + var(--safe-bottom));
  max-width: 560px;
  margin: 0 auto;
}
h2 { font-size: 17px; margin: 18px 0 10px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }

.day-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.phase-label { color: var(--accent); font-size: 13px; font-weight: 600; }
.day-head h2 { margin: 4px 0; }
.day-meta { color: var(--muted); font-size: 14px; }

.chip {
  white-space: nowrap;
  background: var(--bg-card2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px;
  min-height: 44px;
  cursor: pointer;
}
.chip.danger { color: var(--danger); border-color: var(--danger); }
.mini {
  background: var(--bg-card2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 16px;
  cursor: pointer;
}

.btn-primary {
  display: block;
  width: 100%;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 17px;
  font-weight: 700;
  margin: 14px 0;
  min-height: 52px;
  cursor: pointer;
}
.btn-primary.outline {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.btn-primary:active { transform: scale(.98); }

.circuit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0;
  font-weight: 600;
}

.exercise-list { list-style: none; margin: 0; padding: 0; }
.ex-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
  cursor: pointer;
}
.ex-card.done { opacity: .55; }
.ex-card.done .ex-name { text-decoration: line-through; }
.ex-thumb { width: 84px; flex: 0 0 84px; color: var(--fg); }
.ex-info { flex: 1; min-width: 0; }
.ex-name { font-weight: 600; font-size: 15px; }
.ex-dose { color: var(--accent); font-size: 14px; font-weight: 600; }
.ex-group { color: var(--muted); font-size: 12px; }
.ex-check {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  color: transparent;
  font-size: 20px;
  cursor: pointer;
}
.ex-card.done .ex-check { background: var(--ok); border-color: var(--ok); color: #fff; }

/* SVG demo stick-figure */
.ex-thumb svg, .sheet-demo svg { width: 100%; height: auto; display: block; }
svg { stroke: currentColor; fill: none; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
svg circle { fill: currentColor; stroke: none; }
svg .gnd { stroke-width: 2.5; opacity: .35; }
svg .f2 { opacity: 0; }
.anim svg .f1 { animation: fr1 1.6s steps(1, end) infinite; }
.anim svg .f2 { animation: fr2 1.6s steps(1, end) infinite; }
@keyframes fr1 { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes fr2 { 0%, 49% { opacity: 0; } 50%, 100% { opacity: 1; } }

/* Rest bar deasupra tab-bar-ului */
.rest-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(64px + var(--safe-bottom));
  display: flex;
  justify-content: center;
  z-index: 15;
  pointer-events: none;
}
.rest-bar > * { pointer-events: auto; }
.rest-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* Tab bar: fundalul atinge marginea ecranului, padding înăuntru */
.tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom, env(safe-area-inset-bottom, 0px));
  z-index: 20;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 0 6px;
  min-height: 56px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tab-ico { font-size: 20px; }
.tab.active { color: var(--accent); font-weight: 600; }

/* Sheet (detaliu exercițiu) */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 30;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(16px + var(--safe-bottom));
  z-index: 31;
  max-height: 86vh;
  overflow-y: auto;
  max-width: 560px;
  margin: 0 auto;
}
.sheet-handle {
  width: 42px; height: 5px;
  border-radius: 3px;
  background: var(--border);
  margin: 4px auto 10px;
}
.sheet-demo {
  background: var(--bg-card2);
  border-radius: 14px;
  padding: 8px;
  max-width: 320px;
  margin: 0 auto;
  color: var(--fg);
}
.sheet h3 { margin: 12px 0 2px; font-size: 20px; }
.sheet-dose { color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.cues { margin: 8px 0; padding-left: 20px; color: var(--fg); }
.cues li { margin-bottom: 6px; font-size: 14px; line-height: 1.45; }

.yt-link {
  display: block;
  text-align: center;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  line-height: 20px;
}
.yt-link:active { background: var(--border); }

.ex-timer { text-align: center; margin: 10px 0; }
.ex-time {
  font-size: 56px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.ex-time.running { color: var(--ok); }
.ex-timer-btns { display: flex; gap: 10px; }
.ex-timer-btns .btn-primary { flex: 1; margin: 8px 0; }
.ex-timer-btns .chip { align-self: center; }
.ex-side { margin-top: 6px; font-weight: 600; color: var(--muted); }

/* Istoric */
.week-strip { display: flex; gap: 8px; }
.wday {
  flex: 1;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 0;
  font-size: 12px;
  color: var(--muted);
}
.wday .dot {
  display: block;
  width: 22px; height: 22px;
  line-height: 22px;
  margin: 6px auto 0;
  border-radius: 50%;
  background: var(--bg-card2);
  color: transparent;
}
.wday.done .dot { background: var(--ok); color: #fff; font-size: 13px; }
.wday.today { border-color: var(--accent); color: var(--accent); }
.stats {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}
.stat {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}
.stat b { display: block; font-size: 22px; color: var(--accent); }
.stat span { font-size: 12px; color: var(--muted); }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.history-list .muted { font-size: 13px; }
.settings { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.field {
  display: block;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--fg);
  font-size: 16px; /* sub 16px iOS face zoom la focus */
  padding: 12px 14px;
  margin: 8px 0;
  min-height: 48px;
}
.field:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* Program overview */
.pv-phase {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.pv-phase h3 { margin: 0 0 4px; font-size: 15px; }
.pv-phase .muted { font-size: 13px; }
.pv-phase ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.phase-picker { display: flex; gap: 10px; }
.phase-picker .chip.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 700;
}

@media (min-width: 760px) {
  main { max-width: 680px; }
  .ex-thumb { width: 110px; flex-basis: 110px; }
}
