/* Workout Timer — mobile-first, iOS safe-area, fullscreen fase-kleuren */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0d1321;
  --card: #1a2233;
  --text: #f2f5fa;
  --muted: #8b96ab;
  --accent: #34d399;
  --work: #15803d;
  --rest: #b91c1c;
  --break: #1d4ed8;
  --ready: #b45309;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) 20px calc(env(safe-area-inset-bottom) + 16px);
  flex-direction: column;
}
.screen.active { display: flex; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- Iconen ---------- */
.icon { width: 22px; height: 22px; display: block; }
.icon-btn .icon { width: 21px; height: 21px; }
.timer-close .icon { width: 20px; height: 20px; }
.t-skip .icon { width: 24px; height: 24px; }
.t-pause .icon { width: 34px; height: 34px; }
.icon.trophy { width: 84px; height: 84px; color: var(--accent); margin: 0 auto; }
.icon.h-ok { width: 20px; height: 20px; color: var(--accent); }
button .icon { pointer-events: none; }
.icon-btn, .timer-close, .t-skip, .t-pause, .sheet-close {
  display: flex; align-items: center; justify-content: center;
}
.sheet-close .icon { width: 17px; height: 17px; }

/* ---------- Home ---------- */
.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.home-header h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.home-header .icon-btns { display: flex; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.home-sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }

.block-card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.block-card h2 {
  font-size: 15px; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center;
}
.block-card h2 .block-meta { color: var(--muted); font-weight: 500; font-size: 13px; }
.block-card.skipped { opacity: 0.45; }
.ex-row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 0;
}
.ex-row + .ex-row { border-top: 1px solid rgba(255,255,255,0.06); }
.ex-row .exfig-small { width: 40px; height: 40px; flex: none; color: var(--accent); }
.ex-row .ex-name { font-size: 15px; font-weight: 600; }
.ex-row .ex-cue { font-size: 12px; color: var(--muted); }

.start-btn {
  margin-top: auto;
  background: var(--accent);
  color: #06281c;
  font-size: 22px;
  font-weight: 800;
  border-radius: 18px;
  padding: 18px;
  width: 100%;
  letter-spacing: 0.5px;
}
.start-btn:active { transform: scale(0.98); }
.total-time { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }

/* ---------- Timer ---------- */
#timer-screen { transition: background-color 0.4s ease; padding-left: 24px; padding-right: 24px; }
#timer-screen.phase-work { background: var(--work); }
#timer-screen.phase-rest { background: var(--rest); }
#timer-screen.phase-blockrest { background: var(--break); }
#timer-screen.phase-getready { background: var(--ready); }

.timer-top {
  display: flex; justify-content: space-between; align-items: center;
}
.timer-close {
  width: 44px; height: 44px;
  font-size: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.25);
}
.timer-progress { text-align: right; }
.timer-block-label { font-size: 15px; font-weight: 700; opacity: 0.95; }
.round-dots { display: flex; gap: 6px; justify-content: flex-end; margin-top: 5px; }
.round-dots .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,0.3);
}
.round-dots .dot.done { background: rgba(255,255,255,0.95); }

.timer-main {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  min-height: 0;
}
.phase-label {
  font-size: 17px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 2.5px;
  opacity: 0.85;
}
.ex-title { font-size: 30px; font-weight: 800; margin-top: 4px; line-height: 1.15; }
.ex-cue-line { font-size: 14px; opacity: 0.8; margin-top: 4px; min-height: 18px; }
.timer-main .exfig { width: min(34vw, 150px); height: min(34vw, 150px); margin: 6px 0 0; }
.big-time {
  font-size: min(37vw, 168px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.02;
  letter-spacing: -2px;
}
.big-time.pulse { animation: numpulse 1s ease infinite; }
@keyframes numpulse {
  0% { transform: scale(1); }
  12% { transform: scale(1.08); }
  30% { transform: scale(1); }
}

.next-up {
  text-align: center;
  font-size: 15px;
  opacity: 0.9;
  min-height: 22px;
  margin-bottom: 12px;
}
.next-up b { font-weight: 800; }

.transport {
  display: flex; justify-content: center; align-items: center; gap: 26px;
  padding-bottom: 4px;
}
.transport button {
  border-radius: 50%;
  background: rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
}
.transport .t-skip { width: 60px; height: 60px; font-size: 22px; }
.transport .t-pause { width: 84px; height: 84px; font-size: 34px; }
.paused-overlay-label {
  text-align: center; font-weight: 800; letter-spacing: 2px;
  text-transform: uppercase; font-size: 14px;
  margin-bottom: 8px; opacity: 0.9;
  visibility: hidden;
}
.paused .paused-overlay-label { visibility: visible; }

/* Stick figures: 2-pose wissel */
.exfig .pose-a { animation: poseflip-a 1.7s linear infinite; }
.exfig .pose-b { animation: poseflip-b 1.7s linear infinite; }
.exfig-static .pose-a { animation: none; opacity: 1; }
@keyframes poseflip-a {
  0%, 49.9% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes poseflip-b {
  0%, 49.9% { opacity: 0; }
  50%, 100% { opacity: 1; }
}
.paused .exfig .pose-a, .paused .exfig .pose-b { animation-play-state: paused; }

/* ---------- Done ---------- */
#done-screen { text-align: center; justify-content: center; gap: 10px; }
#done-screen h2 { font-size: 30px; font-weight: 800; }
#done-screen .done-stats { color: var(--muted); font-size: 16px; line-height: 1.6; }
#done-screen .start-btn { margin-top: 28px; flex: none; }

/* ---------- Sheets (instellingen / historie) ---------- */
.sheet {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  z-index: 50;
}
.sheet.open { display: block; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 18px 20px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 82dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.sheet-panel h2 { font-size: 19px; font-weight: 800; margin-bottom: 14px; }
.sheet-close {
  position: absolute; top: 14px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  font-size: 17px;
}

.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.setting-row .s-label { font-size: 15px; font-weight: 600; }
.setting-row .s-hint { font-size: 12px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper button {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  font-size: 20px; font-weight: 700;
}
.stepper .s-value {
  min-width: 64px; text-align: center;
  font-size: 16px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.toggle {
  width: 52px; height: 32px;
  border-radius: 16px;
  background: rgba(255,255,255,0.15);
  position: relative;
  transition: background 0.2s;
}
.toggle::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(20px); }
.sheet-panel .reset-link {
  display: block; margin: 16px auto 0;
  color: var(--muted); font-size: 14px; text-decoration: underline;
}

/* Historie */
.hist-week {
  background: rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 15px; font-weight: 600;
}
.hist-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 15px;
}
.hist-item .h-date { font-weight: 600; }
.hist-item .h-meta { color: var(--muted); font-size: 13px; }
.hist-item .h-check { font-size: 17px; }
.hist-empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 14px; }

/* Bevestig-dialoog stoppen */
.confirm-box {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center; justify-content: center;
  z-index: 60;
  padding: 32px;
}
.confirm-box.open { display: flex; }
.confirm-inner {
  background: var(--card);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  width: 100%;
  max-width: 320px;
}
.confirm-inner p { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.confirm-inner .confirm-actions { display: flex; gap: 10px; }
.confirm-inner button {
  flex: 1;
  padding: 13px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
}
.confirm-inner .c-cancel { background: rgba(255,255,255,0.1); }
.confirm-inner .c-stop { background: #dc2626; }
