/* =============================================
   VIRE – Parempana joka päivä.
   ============================================= */

:root {
  --primary:       #1b4332;
  --primary-mid:   #2d6a4f;
  --primary-light: #40916c;
  --accent:        #4ade80;
  --accent-light:  #86efac;
  --highlight:     #facc15;
  --danger:        #f87171;

  /* ── Dark mode ── */
  --bg:            #080f0c;
  --bg2:           #0d1f17;
  --card:          #0f1f17;
  --card2:         #162a1f;
  --text:          #f0fdf4;
  --text-muted:    rgba(240,253,244,0.55);
  --border:        rgba(74,222,128,0.12);
  --border-mid:    rgba(74,222,128,0.22);

  --shadow-sm:     0 1px 6px rgba(0,0,0,0.4);
  --shadow:        0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.6);
  --radius-sm:     8px;
  --radius:        14px;
  --radius-lg:     20px;
  --nav-height:    64px;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  /* iPhone notch + Dynamic Island */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  /* Estä iOS double-tap zoom */
  touch-action: manipulation;
  /* Poista iOS highlight naputettaessa */
  -webkit-tap-highlight-color: transparent;
}

/* ---- TYPOGRAPHY ---- */
h1 { font-size: clamp(1.5rem, 5vw, 2.2rem); font-weight: 800; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 4vw, 1.6rem); font-weight: 700; }
h3 { font-size: clamp(1rem, 3vw, 1.2rem); font-weight: 600; }
h4 { font-size: 0.95rem; font-weight: 600; }
p  { color: var(--text-muted); font-size: 0.95rem; }

a { color: inherit; text-decoration: none; }

/* ---- TOP HEADER ---- */
.site-header {
  background: linear-gradient(160deg, #0d2a1c 0%, #1b4332 60%, #0d1f17 100%);
  color: #fff;
  padding: 32px 20px 36px;
  position: relative;
  overflow: hidden;
}
.site-header::before {
  content: '';
  position: absolute;
  top: -80px; right: -60px;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(74,222,128,0.08) 0%, transparent 70%);
  border-radius: 50%;
}
.site-header::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -20px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(74,222,128,0.05) 0%, transparent 70%);
  border-radius: 50%;
}
.header-inner { position: relative; z-index: 1; max-width: 700px; }
.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(74,222,128,0.15);
  border: 1px solid rgba(134,239,172,0.3);
  color: #86efac;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  padding: 5px 14px 5px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
}
.site-header h1 {
  color: #fff;
  margin-bottom: 6px;
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.03em;
}
.site-header p { color: rgba(255,255,255,0.7); font-size: 0.95rem; margin-top: 4px; }
.header-stats {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
}
.stat-pill .icon { font-size: 1rem; }

/* ---- BOTTOM NAV ---- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: color 0.2s, background 0.2s;
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
}
.nav-item .nav-icon { font-size: 1.4rem; line-height: 1; }
.nav-item:hover, .nav-item.active {
  color: var(--accent);
  background: rgba(74,222,128,0.07);
}
.nav-item.active .nav-icon { filter: drop-shadow(0 0 4px var(--accent)); }

/* ---- MAIN CONTENT ---- */
.main { max-width: 720px; margin: 0 auto; padding: 20px 16px; }

/* ---- CARDS ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-header .icon-box {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.card-header h3 { margin: 0; font-size: 1rem; }
.card-header p  { font-size: 0.8rem; margin: 0; }
.card-body { padding: 16px 18px; }

/* ---- COLOR BADGES ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-green  { background: rgba(74,222,128,0.15);  color: #4ade80; }
.badge-blue   { background: rgba(56,189,248,0.15);  color: #38bdf8; }
.badge-orange { background: rgba(250,204,21,0.15);  color: #facc15; }
.badge-red    { background: rgba(248,113,113,0.15); color: #f87171; }
.badge-purple { background: rgba(192,132,252,0.15); color: #c084fc; }
.badge-gray   { background: rgba(255,255,255,0.08); color: rgba(240,253,244,0.6); }

/* ---- SECTION TITLE ---- */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 0 14px;
}
.section-title .stitle-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-mid), var(--accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.section-title h2 { margin: 0; }
.section-title p { margin: 0; font-size: 0.82rem; }

/* ---- MEAL ROWS ---- */
.meal-row {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.meal-row:last-child { border-bottom: none; padding-bottom: 0; }
.meal-type {
  min-width: 70px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-light);
  padding-top: 2px;
  flex-shrink: 0;
}
.meal-content { flex: 1; }
.meal-content strong { font-size: 0.88rem; color: var(--text); display: block; line-height: 1.3; }
.meal-content span { font-size: 0.78rem; color: var(--text-muted); }
.meal-kcal {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(74,222,128,0.12);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ---- ACCORDIONS ---- */
.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 10px;
}
.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border: none;
  cursor: pointer;
  text-align: left;
  gap: 10px;
  transition: background 0.2s;
}
.accordion-header:hover { background: var(--card2); }
.accordion-header.open { background: var(--bg2); }
.accordion-left { display: flex; align-items: center; gap: 10px; }
.accordion-day-badge {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-mid), var(--accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
}
.accordion-title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.accordion-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.accordion-arrow {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: transform 0.3s;
  flex-shrink: 0;
}
.accordion-header.open .accordion-arrow { transform: rotate(180deg); }
.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
  background: var(--bg2);
}
.accordion-body.open { max-height: 2000px; }
.accordion-inner { padding: 14px 16px 16px; }

/* ---- WORKOUT CARDS ---- */
.workout-day-card {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.workout-day-header {
  padding: 18px 18px 14px;
  color: #fff;
}
.workout-day-header.day-a { background: linear-gradient(135deg, #1b4332, #2d6a4f); }
.workout-day-header.day-b { background: linear-gradient(135deg, #1e3a5f, #2563eb); }
.workout-day-header.day-c { background: linear-gradient(135deg, #6b21a8, #9333ea); }
.workout-day-header.day-d { background: linear-gradient(135deg, #92400e, #f59e0b); }
.workout-day-tag {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}
.workout-day-header h3 { color: #fff; font-size: 1.1rem; margin-bottom: 4px; }
.workout-day-header p  { color: rgba(255,255,255,0.75); font-size: 0.82rem; }
.workout-exercises { background: var(--card); padding: 14px 18px; }
.exercise-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.exercise-item:last-child { border-bottom: none; padding-bottom: 0; }
.ex-number {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: rgba(74,222,128,0.1);
  border: 1px solid rgba(74,222,128,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}
.ex-info { flex: 1; }
.ex-name { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.ex-detail { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.ex-sets {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(74,222,128,0.12);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ---- RECIPE CARDS ---- */
.recipe-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
}
.recipe-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.recipe-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.recipe-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.recipe-body { padding: 16px 18px; }
.recipe-section-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-light);
  margin-bottom: 8px;
  margin-top: 14px;
}
.recipe-section-label:first-child { margin-top: 0; }
.ingredient-list { list-style: none; }
.ingredient-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.88rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.ingredient-list li::before {
  content: '●';
  color: var(--accent);
  font-size: 0.5rem;
  flex-shrink: 0;
}
.steps-list { list-style: none; counter-reset: steps; }
.steps-list li {
  counter-increment: steps;
  display: flex;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--bg);
  align-items: flex-start;
}
.steps-list li:last-child { border-bottom: none; }
.steps-list li::before {
  content: counter(steps);
  min-width: 24px; height: 24px;
  background: linear-gradient(135deg, var(--primary-mid), var(--accent));
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
}
.nutrition-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.nut-box {
  text-align: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
}
.nut-val { font-size: 1rem; font-weight: 800; color: var(--primary-mid); }
.nut-label { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; }

/* ---- INFO BOXES ---- */
.info-box {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.info-box .ib-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.info-box p { font-size: 0.85rem; margin: 0; }
.info-box strong { font-size: 0.85rem; display: block; margin-bottom: 3px; }
.info-green  { background: #d1fae5; border-left: 3px solid #059669; }
.info-orange { background: #fff3cd; border-left: 3px solid #f59e0b; }
.info-red    { background: #fde8e8; border-left: 3px solid #dc2626; }
.info-blue   { background: #dbeafe; border-left: 3px solid #3b82f6; }

/* ---- PROGRESS / STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-icon { font-size: 1.8rem; margin-bottom: 6px; }
.stat-card .stat-val  { font-size: 1.3rem; font-weight: 800; color: var(--primary-mid); }
.stat-card .stat-lbl  { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- WEEK TABS ---- */
.week-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.week-tab {
  flex-shrink: 0;
  padding: 8px 20px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.week-tab.active {
  background: var(--primary-mid);
  border-color: var(--primary-mid);
  color: #fff;
}

/* ---- FILTER BUTTONS ---- */
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn.active, .filter-btn:hover {
  background: var(--primary-mid);
  border-color: var(--primary-mid);
  color: #fff;
}

/* ---- WEEKLY SCHEDULE ---- */
.week-schedule {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}
.day-chip {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.day-chip.workout { background: #d1fae5; color: #065f46; }
.day-chip.rest    { background: #f3f4f6; color: #9ca3af; }
.day-chip.active  { background: var(--primary-mid); color: #fff; }

/* ---- PROGRESS BAR ---- */
.progress-bar-wrap { background: var(--bg); border-radius: 20px; overflow: hidden; height: 8px; }
.progress-bar-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--primary-mid), var(--accent));
  transition: width 1s ease;
}

/* ---- DIVIDER ---- */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ---- FOOTER ---- */
.footer {
  text-align: center;
  padding: 20px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---- RESPONSIVE ---- */

/* Puhelin – pieni (< 375px, esim. iPhone SE) */
@media (max-width: 374px) {
  .header-inner h1 { font-size: 1.4rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .hero-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .bottom-nav .nav-item { font-size: 0.58rem; }
  .bottom-nav .nav-item .nav-icon { font-size: 1.2rem; }
}

/* Puhelin – normaali (375px–499px) */
@media (min-width: 375px) and (max-width: 499px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Tabletti+ (500px+) */
@media (min-width: 500px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .hero-cards { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 24px 24px; }
}

/* ── Desktop (768px+) ──────────────────────────────────────── */
@media (min-width: 768px) {

  /* Bottom nav → Top nav */
  .bottom-nav {
    top: 0;
    bottom: auto;
    left: 0;
    right: 0;
    max-width: none;
    transform: none;
    border-radius: 0;
    border-top: none;
    border-bottom: 1px solid var(--border);
    height: 62px;
    padding: 0 32px;
    justify-content: flex-end;
    gap: 4px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.35);
  }

  /* "vire" wordmark vasemmalla */
  .bottom-nav::before {
    content: 'vire';
    font-family: var(--font);
    font-weight: 900;
    font-size: 1.3rem;
    color: var(--accent);
    letter-spacing: -0.05em;
    margin-right: auto;
    display: flex;
    align-items: center;
  }

  /* Nav-itemit vaakasuoraan */
  .nav-item {
    flex: none;
    flex-direction: row;
    gap: 6px;
    padding: 0 14px;
    font-size: 0.78rem;
    min-height: 62px;
    letter-spacing: 0.02em;
    border-radius: 0;
  }
  .nav-item .nav-icon { font-size: 1.1rem; }

  /* Body: top padding, ei bottom */
  body {
    padding-bottom: 0;
    padding-top: 62px;
  }

  /* Header */
  .site-header { padding: 48px 48px 52px; }
  .header-inner { max-width: 900px; }
  .header-badge { font-size: 0.95rem; padding: 7px 18px 7px 12px; }
  .header-badge svg { width: 28px; height: 28px; }

  /* Sisältö */
  .main { max-width: 960px; padding: 36px 48px; }
  .hero-cards { grid-template-columns: repeat(4, 1fr); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* iPhone notch / Dynamic Island – varmistus */
@supports (padding: max(0px)) {
  .bottom-nav {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  }
  body {
    padding-bottom: calc(var(--nav-height) + max(0px, env(safe-area-inset-bottom)));
  }
}

/* Estä iOS-zoom inputeilla (min 16px) */
input, select, textarea {
  font-size: max(16px, 1rem);
}

/* iOS Safari – poista sisäänrakennettu style */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea {
  -webkit-appearance: none;
  appearance: none;
  border-radius: var(--radius-sm);
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border-mid);
  padding: 10px 14px;
  width: 100%;
}

/* Nappi minikoko iOS HIG: 44px */
button, .btn, .nav-item, .tab-btn, a.hero-card {
  min-height: 44px;
}

/* ---- PRINT STYLES ---- */
@media print {
  body { padding-bottom: 0; background: #fff; }
  .bottom-nav, .filter-row, .week-tabs { display: none !important; }
  .card, .accordion-item, .workout-day-card, .recipe-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  .accordion-body { max-height: none !important; display: block !important; }
  .site-header { background: var(--primary) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ============================================
   PAGE TABS – käytetään treeni.html + muut
   ============================================ */
.page-tabs {
  display: flex;
  gap: 0;
  background: var(--card);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 80;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.page-tabs::-webkit-scrollbar { display: none; }

.ptab {
  flex: 1;
  min-width: 70px;
  padding: 12px 6px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
  white-space: nowrap;
  text-align: center;
}
.ptab.active {
  color: var(--primary-mid);
  border-bottom-color: var(--primary-mid);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============================================
   PROGRAM CARDS
   ============================================ */
.prog-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.prog-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.prog-color-bar {
  width: 5px;
  border-radius: 3px;
  align-self: stretch;
  flex-shrink: 0;
}
.prog-card-meta { flex: 1; }
.prog-card-meta h3 { font-size: 0.95rem; color: var(--text); margin-bottom: 2px; }
.prog-card-meta p  { font-size: 0.75rem; color: var(--text-muted); margin: 0; }
.prog-card-chevron { color: var(--text-muted); font-size: 0.8rem; transition: transform 0.2s; }
.prog-card-chevron.open { transform: rotate(90deg); }

.prog-days {
  border-top: 1px solid var(--border);
  display: none;
}
.prog-days.open { display: block; }

.day-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.day-row:last-child { border-bottom: none; }
.day-row-info { flex: 1; }
.day-row-info strong { font-size: 0.88rem; display: block; color: var(--text); }
.day-row-info span   { font-size: 0.75rem; color: var(--text-muted); }
.btn-start-workout {
  background: var(--primary-mid);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, transform 0.1s;
}
.btn-start-workout:active { transform: scale(0.96); }
.btn-start-workout:hover  { background: var(--primary); }

.prog-card-actions {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.btn-prog-action {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  transition: all 0.15s;
}
.btn-prog-action.delete { color: var(--danger); border-color: #fcd; }
.btn-prog-action:hover  { background: var(--bg); }

/* ============================================
   LIVE WORKOUT
   ============================================ */
.live-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
  color: #fff;
  padding: 20px 20px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.live-header-info { flex: 1; }
.live-header-info h2 { font-size: 1rem; color: #fff; margin-bottom: 2px; }
.live-header-info p  { font-size: 0.8rem; color: rgba(255,255,255,0.75); margin: 0; }
.timer-display {
  font-family: -apple-system-monospaced, 'SF Mono', Menlo, monospace;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.04em;
  text-align: right;
}

.live-exercise-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.live-ex-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.live-ex-header h4 { flex: 1; font-size: 0.92rem; margin: 0; color: var(--text); }
.live-ex-progress {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.set-table {
  width: 100%;
  border-collapse: collapse;
}
.set-table th {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
.set-row td {
  padding: 8px 4px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.set-row:last-child td { border-bottom: none; }
.set-row.done { background: #f0fdf4; }
.set-row.done td { color: var(--text-muted); }
.set-num { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; }

.num-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.num-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  color: var(--primary-mid);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s;
}
.num-btn:active { background: var(--accent-light); }
.num-val {
  min-width: 40px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}
.btn-set-done {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.btn-set-done.done {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.set-last-ref {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* ============================================
   EXERCISE BROWSER
   ============================================ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.search-bar input {
  flex: 1;
  border: none;
  background: none;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
}
.search-bar span { color: var(--text-muted); }

.filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  margin-bottom: 14px;
  padding-bottom: 2px;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.chip.active {
  background: var(--primary-mid);
  border-color: var(--primary-mid);
  color: #fff;
}

.ex-browser-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.ex-browser-item:last-child { border-bottom: none; }
.mg-badge {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--primary-mid);
  border: 1px solid var(--accent-light);
  white-space: nowrap;
}
.eq-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ============================================
   WORKOUT HISTORY
   ============================================ */
.hist-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.hist-stat-box {
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 12px 10px;
  text-align: center;
}
.hist-stat-box .num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary-mid);
  display: block;
  line-height: 1.1;
}
.hist-stat-box .lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

.hist-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.hist-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.hist-card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.hist-card-info { flex: 1; }
.hist-card-info h4 { font-size: 0.9rem; color: var(--text); margin-bottom: 2px; }
.hist-card-info p  { font-size: 0.75rem; color: var(--text-muted); margin: 0; }
.hist-card-date { font-size: 0.73rem; color: var(--text-muted); }
.hist-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.hist-pill {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.hist-pill.green { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }

/* ============================================
   MODAL / OVERLAY
   ============================================ */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.overlay.open { display: flex; align-items: flex-end; }
.sheet {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0 0 env(safe-area-inset-bottom);
}
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}
.sheet-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.sheet-header h3 { flex: 1; font-size: 1rem; margin: 0; }
.sheet-body { padding: 16px 20px; }

.form-field { margin-bottom: 14px; }
.form-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-field input, .form-field select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}
.form-field input:focus, .form-field select:focus {
  border-color: var(--primary-mid);
}
.color-swatch-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.color-swatch.selected { border-color: var(--text); transform: scale(1.15); }

/* ---- UTILITY ---- */
.flex   { display: flex; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-0   { margin-bottom: 0; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.mt-8   { margin-top: 8px; }
.mt-12  { margin-top: 12px; }
.fw-700 { font-weight: 700; }
.text-center { text-align: center; }
.text-sm { font-size: 0.82rem; }
.text-muted { color: var(--text-muted); }
.w-full { width: 100%; }

/* ── Auth: käyttäjäpalkki ── */
.vire-user-bar {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 10px 6px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  z-index: 200;
  box-shadow: var(--shadow);
}
.vire-logout-btn {
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.vire-logout-btn:hover { background: var(--primary); }

@media (min-width: 768px) {
  .vire-user-bar {
    bottom: auto;
    top: 14px;
    right: 20px;
    position: fixed;
  }
}
