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

:root {
  --orange: #f97316;
  --orange-dark: #ea580c;
  --orange-light: #fff7ed;
  --green: #22c55e;
  --green-dark: #16a34a;
  --blue: #3b82f6;
  --teal: #14b8a6;
  --red: #ef4444;
  --purple: #8b5cf6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
}

/* HEADER */
header {
  background: var(--gray-900);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--orange);
  background: rgba(249,115,22,.15);
  border: 2px solid rgba(249,115,22,.4);
  border-radius: 8px;
  padding: 6px 10px;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-subtitle {
  font-size: 0.78rem;
  color: var(--gray-400);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.countdown {
  text-align: center;
}

.countdown-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--orange);
  line-height: 1;
}

.countdown-label {
  font-size: 0.65rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
}

.user-pill span {
  font-weight: 600;
  color: white;
}

.change-user-btn {
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.change-user-btn:hover { color: white; }

/* LOGIN OVERLAY */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px 36px;
  width: 360px;
  max-width: calc(100vw - 40px);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  font-size: 2rem;
  font-weight: 800;
  color: var(--orange);
  background: var(--orange-light);
  border-radius: 12px;
  padding: 10px 16px;
  display: inline-block;
  margin-bottom: 16px;
}

.login-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.login-card p {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#name-input {
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1rem;
  color: var(--gray-800);
  outline: none;
  transition: border-color 0.15s;
}

#name-input:focus {
  border-color: var(--orange);
}

#login-form button {
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

#login-form button:hover { background: var(--orange-dark); }
#login-form button:active { transform: scale(0.98); }

/* MAIN */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* PROGRESS BAR */
.progress-bar-wrap {
  background: var(--gray-200);
  border-radius: 999px;
  height: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}

.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), #fb923c);
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* STATS */
.stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow);
  flex: 1;
  min-width: 120px;
}

.stat-card .stat-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.73rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* CALENDAR */
.phase-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin: 32px 0 10px;
  padding-left: 2px;
}

.phase-header:first-child { margin-top: 0; }

.week-block {
  margin-bottom: 12px;
}

.week-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 6px;
  padding-left: 2px;
}

.week-label.current-week .week-label-text {
  color: var(--orange);
}

.week-sessions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 560px) {
  .week-sessions { grid-template-columns: 1fr; }
}

/* SESSION CARD */
.session-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
}

.session-card.is-done {
  border-color: var(--green);
  background: #f0fdf4;
}

.session-card.is-race {
  background: linear-gradient(135deg, #fdf4ff, #fef3c7);
  border-color: var(--purple);
}

.session-card:hover { transform: translateY(-1px); }

.session-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.session-date {
  font-size: 0.75rem;
  color: var(--gray-400);
  font-weight: 500;
}

.type-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.type-badge.easy      { background: #dcfce7; color: #15803d; }
.type-badge.fartlek   { background: #ccfbf1; color: #0f766e; }
.type-badge.tempo     { background: #ffedd5; color: #c2410c; }
.type-badge.intervals { background: #fee2e2; color: #b91c1c; }
.type-badge.long      { background: #dbeafe; color: #1d4ed8; }
.type-badge.race      { background: #ede9fe; color: #6d28d9; }

.session-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.session-title.race-title {
  font-size: 1.05rem;
  color: var(--purple);
}

.session-distance {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}

.session-distance span {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-400);
}

.session-desc {
  font-size: 0.8rem;
  color: var(--gray-500);
  line-height: 1.5;
}

.session-completions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 24px;
}

.completion-chip {
  font-size: 0.72rem;
  font-weight: 600;
  background: #dcfce7;
  color: #15803d;
  border-radius: 999px;
  padding: 3px 9px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.completion-chip::before {
  content: '✓';
  font-size: 0.65rem;
}

.session-footer {
  margin-top: auto;
}

.complete-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.complete-btn:active { transform: scale(0.97); }

.complete-btn.not-done {
  background: var(--orange);
  color: white;
}

.complete-btn.not-done:hover { background: var(--orange-dark); }

.complete-btn.done {
  background: var(--green);
  color: white;
}

.complete-btn.done:hover { background: var(--green-dark); }

.complete-btn.race-btn {
  background: var(--purple);
  color: white;
  font-size: 0.95rem;
  padding: 12px;
}

.complete-btn.race-btn:hover { background: #7c3aed; }

/* Current week highlight */
.week-block.current-week .week-label {
  color: var(--orange);
  font-weight: 700;
}

.current-week-tag {
  background: var(--orange);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
