:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --accent: #ff6b35;
  --text: #ffffff;
  --text-dim: #7878a0;
  --card: #16213e;
  --danger: #ff4444;
  --warn: #ffaa00;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 430px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
}

/* ── Header ── */
.header {
  padding: 18px 22px 10px;
}

.logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo span { color: var(--accent); }

.btn-mute {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.btn-mute:active { color: var(--text); }
.btn-mute.muted  { color: var(--accent); }

/* ── Timer area ── */
.timer-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 10px 20px;
}

/* Reps dots badge */
.reps-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 50px;
  padding: 8px 18px;
}

.reps-label {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.reps-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 160px;
}

.rep-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: background 0.3s, border-color 0.3s;
}

.rep-dot.active  { background: var(--accent); }
.rep-dot.done    { background: transparent; border: 1.5px solid var(--text-dim); }

/* Ring timer */
.timer-ring-container {
  position: relative;
  width: min(260px, 60vw);
  height: min(260px, 60vw);
}

.timer-svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.ring-bg {
  fill: none;
  stroke: var(--surface);
  stroke-width: 12;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  transition: none;
}

.timer-display {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.timer-time {
  font-size: clamp(48px, 14vw, 64px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  line-height: 1;
}

.timer-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

/* Controls */
.controls {
  display: flex;
  gap: 20px;
  align-items: center;
}

.btn-reset {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--card);
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
}

.btn-reset:active { transform: scale(0.9); background: var(--surface); }

.btn-play {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 28px rgba(255,107,53,0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-play:active {
  transform: scale(0.9);
  box-shadow: 0 0 10px rgba(255,107,53,0.2);
}

/* ── Bottom panel ── */
.bottom-panel {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 20px 20px 28px;
}

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

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  font-weight: 700;
}

.btn-edit {
  display: none;
}

/* Duration chips */
.durations-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.durations-scroll::-webkit-scrollbar { display: none; }

.duration-chip {
  flex-shrink: 0;
  padding: 10px 18px;
  border-radius: 50px;
  background: var(--card);
  border: 2px solid transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.duration-chip.selected {
  border-color: var(--accent);
  background: rgba(255,107,53,0.15);
  color: var(--accent);
}

.duration-chip:active { transform: scale(0.94); }

/* Reps section */
.reps-section { margin-top: 18px; }

.reps-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: 16px;
  padding: 6px;
  margin-top: 12px;
}

.btn-rep {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.12s, background 0.12s;
  user-select: none;
}

.btn-rep:active { transform: scale(0.9); background: var(--bg); }

.reps-number {
  font-size: 36px;
  font-weight: 800;
  min-width: 60px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Edit modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 16px 20px calc(28px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--card);
  border-radius: 2px;
  margin: 0 auto 18px;
}

.modal-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 16px;
}

.duration-edit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 38vh;
  overflow-y: auto;
}

.duration-edit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 14px;
}

.duration-edit-item input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  outline: none;
  width: 0;
  font-family: inherit;
}

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

.btn-delete {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255,50,50,0.15);
  color: #ff5555;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-add-duration {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 14px;
  border: 2px dashed var(--text-dim);
  border-radius: 12px;
  background: none;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-add-duration:active { background: var(--card); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn-cancel {
  flex: 1;
  padding: 16px;
  border-radius: 14px;
  border: 2px solid var(--card);
  background: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-save {
  flex: 2;
  padding: 16px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* ── Finish overlay ── */
.finish-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.finish-overlay.show { opacity: 1; pointer-events: all; }

.finish-icon { font-size: 72px; }

.finish-title { font-size: 34px; font-weight: 800; }

.finish-subtitle { color: var(--text-dim); font-size: 16px; }

.btn-finish {
  margin-top: 14px;
  padding: 16px 44px;
  border-radius: 50px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 0 24px rgba(255,107,53,0.4);
}

/* Pulse animation when running */
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 28px rgba(255,107,53,0.45); }
  50%  { box-shadow: 0 0 44px rgba(255,107,53,0.7); }
  100% { box-shadow: 0 0 28px rgba(255,107,53,0.45); }
}

.btn-play.running { animation: pulse-ring 1.2s ease-in-out infinite; }
