/* 오늘의 세트 — 전역 스타일. 색/글꼴/모양은 전부 CSS 커스텀 프로퍼티로만 지정한다.
   테마 워커가 themes/*.css 에서 :root 변수를 덮어써서 완전히 다른 느낌을 낼 수 있어야 한다. */

:root {
  --bg: #ffffff;
  --surface: #f5f6f8;
  --surface-2: #ebedf1;
  --fg: #111214;
  --muted: #6b7280;
  --border: #e2e4e9;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 16px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: var(--font);
  --font-num: ui-monospace, 'SF Mono', 'Roboto Mono', Menlo, Consolas, monospace;
  --weight-display: 700;
  --display-transform: none;
  --display-tracking: normal;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 10px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1012;
    --surface: #1a1b1e;
    --surface-2: #242529;
    --fg: #f2f3f5;
    --muted: #9aa0ac;
    --border: #2e3036;
    --accent: #3b82f6;
    --accent-fg: #0b1020;
    --danger: #f87171;
    --success: #4ade80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  min-width: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  text-transform: var(--display-transform);
  letter-spacing: var(--display-tracking);
  margin: 0;
  color: var(--fg);
}

p {
  margin: 0;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: screen-fade 0.18s ease;
}

@keyframes screen-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---- 공용 버튼 ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn:active {
  opacity: 0.85;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
}

.btn--secondary {
  background: var(--surface-2);
}

.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
}

.btn--block {
  width: 100%;
}

.btn--lg {
  min-height: 56px;
  font-size: 17px;
}

/* ---- 레이아웃 섹션 ---- */

.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.home-title {
  font-size: 28px;
  padding-top: 8px;
}

/* ---- 홈: 가장 오래 쉰 부위 ---- */

.stalest-line {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.stalest-line--empty {
  cursor: default;
  text-align: center;
}

/* ---- 홈: 부위 선택 칩 ---- */

.part-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* ---- 홈: 추천 운동 리스트 ---- */

.exercise-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exercise-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.exercise-row__info {
  min-width: 0;
  flex: 1;
}

.exercise-row__name {
  font-weight: 700;
  font-size: 16px;
}

.exercise-row__meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.exercise-row__swap {
  flex-shrink: 0;
  min-height: 48px;
  padding: 6px 14px;
  font-size: 13px;
}

/* ---- 홈: 휴식 시간 스테퍼 ---- */

.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper__btn {
  min-width: 48px;
}

.stepper__value {
  flex: 1;
  text-align: center;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 700;
}

/* ---- 홈: 최근 기록 ---- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  min-width: 0;
}

.history-row__date {
  font-weight: 700;
  flex-shrink: 0;
}

.history-row__parts {
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row__duration {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.empty-note {
  color: var(--muted);
  font-size: 14px;
  padding: 12px 0;
}

/* ---- 세션: 상단 고정 바 ---- */

.session-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  margin: -16px -16px 0;
  padding-left: 16px;
  padding-right: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.session-topbar__label {
  font-size: 13px;
  color: var(--muted);
}

.session-topbar__timer {
  margin-right: auto;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
}

.session-topbar__end {
  min-height: 48px;
  padding: 6px 14px;
  font-size: 13px;
}

/* ---- 세션: 스트레칭 카드 ---- */

.stretch-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}

.stretch-card__progress {
  color: var(--muted);
  font-size: 13px;
}

.stretch-card__name {
  font-size: 22px;
}

.stretch-card__cue {
  color: var(--muted);
  font-size: 14px;
}

.stretch-card__timer {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 56px;
  font-weight: 700;
  margin: 10px 0;
}

.stretch-card__actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 8px;
  margin-top: 8px;
}

/* ---- 세션: 운동 카드 ---- */

.exercise-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exercise-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.exercise-card--done {
  opacity: 0.7;
  box-shadow: none;
}

.exercise-card--active {
  border-color: var(--accent);
}

.exercise-card__header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.exercise-card__name {
  font-size: 17px;
  font-weight: 700;
}

.exercise-card__meta {
  color: var(--muted);
  font-size: 13px;
}

.exercise-card__cue {
  color: var(--muted);
  font-size: 13px;
}

.exercise-card__footer {
  display: flex;
  gap: 8px;
}

.exercise-card__footer .btn {
  flex: 1;
}

/* ---- 세션: 세트 점 표시 ---- */

.set-dots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.set-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.set-dot--done {
  background: var(--success);
  border-color: var(--success);
}

.set-dot--current {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- 세션: 세트 진행/휴식 ---- */

.set-status {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.set-timer,
.rest-timer {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 48px;
  font-weight: 700;
  text-align: center;
  margin: 4px 0;
}

.rest-panel__label {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.rest-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rest-actions .btn {
  flex: 1;
  min-width: 90px;
}

.set-input-row {
  display: flex;
  gap: 10px;
}

.set-input {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.set-input__label {
  font-size: 12px;
  color: var(--muted);
}

.set-input__field {
  min-height: 48px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 16px;
}

/* ---- 서머리 ---- */

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 0;
}

.stat__value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 700;
}

.stat__label {
  color: var(--muted);
  font-size: 12px;
}

.summary-exercise-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-exercise {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 0;
}

.summary-exercise__name {
  font-weight: 700;
  font-size: 14px;
}

.summary-exercise__sets {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  word-break: break-word;
}

/* ---- 아주 좁은 화면 보호 ---- */

@media (max-width: 360px) {
  #app {
    padding-left: 16px;
    padding-right: 16px;
  }

  .stretch-card__timer {
    font-size: 48px;
  }

  .set-timer,
  .rest-timer {
    font-size: 40px;
  }
}
