*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F7F5F0;
  --ink: #1A1814;
  --ink-muted: #8A8680;
  --accent: #C8502A;
  --accent-light: #F0E8E3;
  --rule: #DDD9D0;
  --card: #FFFFFF;
  --streak-gold: #C8952A;
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Mono', monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── HEADER ── */
header {
  width: 100%;
  max-width: 520px;
  padding: 2.5rem 2rem 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  animation: fadeUp 0.6s ease both;
}
.back-link {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.back-link:hover { color: var(--ink); }
.logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.logo span { color: var(--accent); font-style: italic; }
.notify-btn {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 2rem;
  cursor: pointer;
  transition: all 0.2s;
}
.notify-btn:hover { border-color: var(--accent); color: var(--accent); }
.notify-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── MAIN ── */
main {
  width: 100%;
  max-width: 520px;
  padding: 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── NEXT WORKOUT CARD ── */
.hero-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 2rem;
  animation: fadeUp 0.6s 0.1s ease both;
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.8s ease;
}
.hero-card.active::before { transform: scaleX(1); }

.card-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
}
.workout-name {
  font-family: 'DM Serif Display', serif;
  font-size: 2.4rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
.workout-sub {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-bottom: 1.75rem;
}

.countdown-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.countdown-time {
  font-size: 3.5rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.countdown-label {
  font-size: 0.65rem;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-bottom: 0.5rem;
}
.interval-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.interval-label {
  font-size: 0.6rem;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex: 1;
}
.interval-btn {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
  padding: 0;
}
.interval-btn:hover { border-color: var(--accent); color: var(--accent); }
.interval-btn:disabled { opacity: 0.3; cursor: default; }
.interval-val {
  font-size: 0.75rem;
  font-weight: 500;
  min-width: 3.5rem;
  text-align: center;
  color: var(--ink);
}

/* ── TIMER RING ── */
.timer-ring-wrap {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 1.5rem;
}
.timer-ring {
  position: relative;
  width: 140px;
  height: 140px;
}
.timer-ring svg {
  transform: rotate(-90deg);
  width: 140px;
  height: 140px;
}
.ring-bg { fill: none; stroke: var(--rule); stroke-width: 4; }
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 408;
  stroke-dashoffset: 408;
  transition: stroke-dashoffset 1s linear;
}
.timer-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.timer-seconds {
  font-size: 2.5rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.timer-label-sm {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}

/* ── BUTTONS ── */
.btn-row {
  display: flex;
  gap: 0.75rem;
}
.btn-primary {
  flex: 1;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { background: var(--accent); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.go { background: var(--accent); }

.btn-secondary {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: none;
  color: var(--ink-muted);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.9rem 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--ink-muted); color: var(--ink); }

/* ── STREAK + PROGRESS ── */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  animation: fadeUp 0.6s 0.2s ease both;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.25rem;
}
.stat-icon { font-size: 1.1rem; margin-bottom: 0.5rem; }
.stat-val {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}
.stat-val.gold { color: var(--streak-gold); }
.stat-name {
  font-size: 0.65rem;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── TODAY'S SESSIONS ── */
.sessions-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.5rem;
  animation: fadeUp 0.6s 0.3s ease both;
}
.sessions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.sessions-title {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.sessions-count {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 500;
}
.sessions-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.4rem;
}
.session-dot {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--rule);
  position: relative;
  transition: all 0.3s;
  cursor: default;
}
.session-dot.done {
  background: var(--accent);
}
.session-dot.done::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: white;
}
.session-dot.current {
  background: var(--accent-light);
  border: 1.5px solid var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}
.session-times {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.session-time {
  font-size: 0.5rem;
  color: var(--ink-muted);
  text-align: center;
  letter-spacing: -0.02em;
}

/* ── WORKOUT LIST ── */
.workouts-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.5rem;
  animation: fadeUp 0.6s 0.4s ease both;
}
.workouts-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1rem;
}
.workout-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: all 0.15s;
}
.workout-item:last-child { border-bottom: none; }
.workout-item:hover .wi-name { color: var(--accent); }
.wi-left { display: flex; flex-direction: column; gap: 0.15rem; }
.wi-name { font-size: 0.85rem; transition: color 0.15s; }
.wi-meta { font-size: 0.6rem; color: var(--ink-muted); letter-spacing: 0.05em; }
.wi-right {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 99px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(4rem);
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.75rem 1.5rem;
  border-radius: 99px;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── ACTIVE WORKOUT OVERLAY ── */
.workout-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.workout-overlay.open { display: flex; }
.wo-label {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}
.wo-name {
  font-family: 'DM Serif Display', serif;
  font-size: 3rem;
  text-align: center;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
.wo-desc {
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-align: center;
  margin-bottom: 3rem;
  max-width: 280px;
}
.big-timer {
  font-size: 7rem;
  font-weight: 500;
  letter-spacing: -0.06em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.5rem;
  transition: color 0.3s;
}
.big-timer.urgent { color: var(--accent); }
.wo-progress-bar {
  width: 200px;
  height: 2px;
  background: var(--rule);
  border-radius: 1px;
  margin-bottom: 3rem;
  overflow: hidden;
}
.wo-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  width: 0%;
  transition: width 1s linear;
}
.wo-done-btn {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 1rem 2.5rem;
  cursor: pointer;
  transition: all 0.2s;
}
.wo-done-btn:hover { background: var(--accent); }
.wo-skip {
  margin-top: 1rem;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
}
.wo-skip:hover { color: var(--ink); }

/* ── COMPLETION OVERLAY ── */
.done-icon {
  font-size: 2rem;
  width: 4.5rem;
  height: 4.5rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wo-share-btn {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: #2A7A4A;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 1.1rem 2.5rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  max-width: 280px;
}
.wo-share-btn:hover { filter: brightness(1.1); }
.wo-share-btn:active { transform: scale(0.98); }

.wo-history-btn {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
  text-align: center;
  background: none;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.9rem 2.5rem;
  text-decoration: none;
  transition: all 0.2s;
  width: 100%;
  max-width: 280px;
  box-sizing: border-box;
  margin-top: 0.75rem;
}
.wo-history-btn:hover { border-color: var(--ink-muted); }

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.pop { animation: pop 0.3s ease; }

/* ── CHIME TOGGLE ── */
.chime-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-muted);
  transition: color 0.2s, border-color 0.2s;
  z-index: 100;
}
.chime-toggle:hover { color: var(--ink); border-color: var(--ink-muted); }
.chime-toggle .icon-off { display: none; }
.chime-toggle.muted { color: var(--ink-muted); }
.chime-toggle.muted .icon-on  { display: none; }
.chime-toggle.muted .icon-off { display: flex; }
