* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f2f4f0;
  color: #172019;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  padding: 22px 20px 8px;
  max-width: 1060px;
  margin: auto;
}

.brand {
  color: #172019;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: #b9f227;
  border-radius: 9px;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  letter-spacing: 0;
  transform: skew(-8deg);
  width: 34px;
}

.container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 12px 14px 30px;
}

.card {
  background: #ffffff;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid rgba(23, 32, 25, 0.07);
  box-shadow: 0 8px 30px rgba(23, 32, 25, 0.055);
}

h2,
h3,
h4 {
  margin-top: 0;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #d7dce5;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 12px;
  background: #fff;
}

textarea.notes-box {
  min-height: 90px;
  resize: vertical;
}

button {
  border: none;
  background: #edf0eb;
  color: #111827;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  cursor: pointer;
}

button.primary {
  background: #172019;
  color: #b9f227;
  font-weight: 750;
}

button.danger {
  background: #b91c1c;
  color: #fff;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.muted {
  color: #6b7280;
  font-size: 14px;
}

.message {
  font-size: 14px;
  margin-top: 10px;
}

.hidden {
  display: none !important;
}

.section-label {
  display: block;
  font-weight: bold;
  margin-bottom: 8px;
}

.day-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.day-btn {
  background: #eef2f7;
}

.day-btn.active {
  background: #172019;
  color: #b9f227;
}

.section-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 18px 0;
}

.exercise-row {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fafbfd;
}

.exercise-row-title {
  font-weight: bold;
  margin-bottom: 10px;
}

.exercise-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.exercise-subfields {
  margin-top: 10px;
}

.exercise-type-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.exercise-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.routine-card,
.history-card,
.workout-exercise-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
}

.day-chip-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.day-chip,
.type-chip,
.pr-chip,
.superset-chip {
  font-size: 12px;
  background: #eef2f7;
  color: #374151;
  border-radius: 999px;
  padding: 6px 10px;
  display: inline-block;
}

.pr-chip {
  background: #fef3c7;
  color: #92400e;
}

.superset-chip {
  background: #ede9fe;
  color: #5b21b6;
}

.superset-group-container {
  border-left: 4px solid #7c3aed;
  background: #faf5ff;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}

.superset-group-container .card.workout-exercise-card {
  margin-bottom: 10px;
  border: 1px solid #ddd6fe;
  box-shadow: none;
}

.superset-group-container .card.workout-exercise-card:last-child {
  margin-bottom: 0;
}

.superset-group-header {
  font-size: 13px;
  font-weight: bold;
  color: #7c3aed;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.superset-group-header::before {
  content: "\1F517";
  font-size: 14px;
}

.superset-group-compact {
  padding: 10px;
}

.superset-group-compact .exercise-item {
  border-top-color: #ddd6fe;
}

.superset-group-hint {
  font-size: 12px;
  color: #7c3aed;
  background: #f5f3ff;
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 10px;
}

.exercise-item {
  border-top: 1px solid #edf0f5;
  padding: 10px 0;
}

.exercise-item:first-of-type {
  border-top: none;
}

.exercise-name {
  font-weight: bold;
  margin-bottom: 4px;
}

.exercise-meta {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
}

.suggestion-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  padding: 14px;
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-box {
  background: #f8fafc;
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}

.stat-number {
  font-size: 28px;
  font-weight: bold;
  color: #172019;
}

.stat-label {
  font-size: 13px;
  color: #6b7280;
  margin-top: 6px;
}

.save-row {
  margin-top: 8px;
}

.empty-state {
  color: #6b7280;
  font-size: 14px;
}

.workout-target {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 10px;
}

.set-row {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafafa;
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
}

.set-row.completed {
  background: #f2fbdc;
  border-color: #9ed020;
}

.set-row.completed .stepper-group {
  opacity: 0.72;
}

.set-row-title {
  font-weight: bold;
  margin-bottom: 8px;
}

.inline-chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.stepper-group {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid #d7dce5;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.stepper-group .stepper-input {
  border: none;
  border-radius: 0;
  border-left: 1px solid #d7dce5;
  border-right: 1px solid #d7dce5;
  margin-bottom: 0;
  text-align: center;
  flex: 1;
  min-width: 0;
  padding: 10px 4px;
  -moz-appearance: textfield;
}

.stepper-group .stepper-input::-webkit-inner-spin-button,
.stepper-group .stepper-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-btn {
  flex-shrink: 0;
  width: 40px;
  height: 100%;
  padding: 10px 0;
  font-size: 18px;
  font-weight: bold;
  border-radius: 0;
  background: #f3f4f6;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:active {
  background: #d1d5db;
}

.eyebrow {
  color: #6f8e1d;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.16em;
  margin: 0 0 8px;
}

.ghost-btn {
  background: transparent;
  border: 1px solid #dfe3dc;
}

.today-card {
  background: linear-gradient(135deg, #172019 0%, #293529 100%);
  color: #fff;
  overflow: hidden;
  padding: 28px;
  position: relative;
}

.today-card::after {
  background: #b9f227;
  border-radius: 50%;
  content: "";
  height: 150px;
  opacity: 0.08;
  position: absolute;
  right: -50px;
  top: -55px;
  width: 150px;
}

.today-card .muted { color: #aeb8af; }
.today-card .suggestion-box {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.2);
}

.hero-action {
  background: #b9f227 !important;
  color: #172019 !important;
  margin-top: 16px;
  min-width: 170px;
}

.mobile-nav { display: none; }

.set-check-label {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-weight: 750;
  gap: 9px;
}

.set-check-label input {
  accent-color: #79a000;
  height: 20px;
  margin: 0;
  width: 20px;
}

.progress-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 14px;
}

.metric-card {
  background: #fff;
  border: 1px solid rgba(23,32,25,.07);
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(23,32,25,.055);
  padding: 18px;
}

.metric-card span { color: #6b7280; display: block; font-size: 12px; }
.metric-card strong { display: block; font-size: 25px; margin-top: 8px; }

.weekly-chart {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(8, 1fr);
  height: 230px;
}

.chart-column {
  align-items: center;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: end;
}

.chart-track {
  align-items: end;
  background: #f0f2ed;
  border-radius: 8px;
  display: flex;
  height: 155px;
  overflow: hidden;
  width: min(38px, 80%);
}

.chart-bar { background: #9fd122; border-radius: 8px 8px 0 0; width: 100%; }
.chart-value { font-size: 12px; font-weight: 750; margin-bottom: 5px; }
.chart-label { color: #7a817b; font-size: 10px; margin-top: 7px; text-align: center; }

.pr-row {
  align-items: center;
  border-top: 1px solid #edf0eb;
  display: flex;
  justify-content: space-between;
  padding: 13px 0;
}
.pr-row:first-child { border-top: 0; }

.week-chip,
.intensity-chip {
  background: #e9f7c4;
  border-radius: 999px;
  color: #46610a;
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 9px;
}

.intensity-chip {
  background: #edf0eb;
  color: #4b554d;
}

.today-plan {
  display: grid;
  gap: 9px;
  justify-items: start;
}

.today-plan strong { font-size: 19px; }
.today-plan p { color: #bdc6be; line-height: 1.5; margin: 0; }

.plan-guidance {
  background: #f7f9f4;
  border-left: 3px solid #9fd122;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
  padding: 11px 13px;
}

.plan-guidance p { color: #626a63; margin: 4px 0 9px; }
.plan-guidance p:last-child { margin-bottom: 0; }
.active-guidance { border-left-width: 5px; }

.exercise-note {
  background: #f5f7f2;
  border-radius: 8px;
  color: #667067;
  font-size: 12px;
  margin: 0 0 12px;
  padding: 8px 10px;
}

.time-control {
  background: #fff;
  border: 1px solid #d7dce5;
  border-radius: 12px;
  padding: 9px;
}

.time-control-label {
  color: #6b7280;
  font-size: 11px;
  font-weight: 750;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.time-input-row {
  align-items: center;
  display: grid;
  gap: 5px;
  grid-template-columns: 1fr auto 1fr;
}

.time-input-row label {
  align-items: center;
  display: flex;
  gap: 4px;
}

.time-input-row input {
  background: #f4f6f2;
  border: 0;
  font-size: 18px;
  font-weight: 750;
  margin: 0;
  min-width: 0;
  padding: 8px 4px;
  text-align: center;
}

.time-input-row label span {
  color: #717971;
  font-size: 10px;
}

.time-colon { font-size: 20px; font-weight: 800; }

.time-quick-row {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 7px;
}

.time-stepper-btn {
  background: #edf0eb;
  border-radius: 7px;
  font-size: 9px;
  font-weight: 700;
  padding: 7px 2px;
}

.notes-details { margin-bottom: 14px; }
.notes-details summary {
  cursor: pointer;
  font-weight: 750;
  list-style: none;
  padding: 4px 0 12px;
}
.notes-details summary::-webkit-details-marker { display: none; }
.notes-details summary::before { content: "+"; margin-right: 8px; }
.notes-details[open] summary::before { content: "−"; }
.notes-details summary span { color: #818981; float: right; font-size: 11px; font-weight: 500; }

.save-toast {
  background: #172019;
  border: 1px solid #b9f227;
  border-radius: 999px;
  bottom: 88px;
  color: #b9f227;
  font-size: 13px;
  font-weight: 800;
  left: 50%;
  padding: 12px 18px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 500;
}

@media (max-width: 700px) {
  body { padding-bottom: 84px; }
  .desktop-nav { display: none; }
  .stats-grid,
  .progress-summary {
    grid-template-columns: 1fr 1fr;
  }

  .exercise-grid,
  .exercise-type-row,
  .day-selector {
    grid-template-columns: 1fr 1fr;
  }

  .topbar { padding: 16px 16px 6px; }
  .container { padding: 8px 12px 25px; }
  .card { border-radius: 16px; padding: 16px; }
  .today-card { padding: 22px; }
  .top-row { align-items: flex-start; }
  .welcome-block h2 { font-size: 21px; }

  .mobile-nav {
    align-items: flex-end;
    background: rgba(255,255,255,.96);
    border-top: 1px solid #e4e7e1;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    left: 0;
    padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    position: fixed;
    right: 0;
    z-index: 100;
  }

  .mobile-nav-btn {
    background: transparent;
    color: #788078;
    display: flex;
    flex-direction: column;
    font-size: 10px;
    gap: 3px;
    padding: 5px 2px;
  }

  .mobile-nav-btn span { font-size: 20px; line-height: 1; }
  .mobile-nav-btn.active { color: #172019; font-weight: 800; }
  .workout-nav-btn span {
    align-items: center;
    background: #b9f227;
    border-radius: 50%;
    color: #172019;
    display: flex;
    height: 39px;
    justify-content: center;
    margin-top: -20px;
    width: 39px;
  }

  #active-workout-view > .workout-finish-card { position: static; }
}

.last-performance {
  background: #f0fdf4;
  border: 1px dashed #86efac;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.last-perf-label {
  font-weight: bold;
  font-size: 13px;
  color: #166534;
  margin-bottom: 4px;
}
