/* Dapp — theme.css(Ohweb Liquid Glass) 위에 얹는 앱 전용 스타일.
   원칙: 색은 상태에만(선택 탭·완료 세트·현재 세트·타이머), 주요 CTA는 중립 다크, 이모지 없음. */

:root {
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tap: 52px;            /* 한 손 조작 최소 터치 높이 */
  --series-1: #2a78d6;    /* dataviz 기본 팔레트 1~3번 (검증된 조합) */
  --series-2: #eb6834;
  --series-3: #1baf7a;
}
body.dark { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; }

body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; color: inherit; touch-action: manipulation; }
input, select { font-family: inherit; }
.spacer { flex: 1; }
.unit { font-size: 1rem; font-weight: 600; color: var(--sub); margin-left: 4px; letter-spacing: 0; }

/* ---------- 잠금 ---------- */
.gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50; }
.login-card {
  width: 100%; max-width: 320px; padding: 32px 24px; border-radius: var(--radius-lg);
  background: var(--glass); display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.login-card img { border-radius: 13px; }
.inp.pin { text-align: center; font-size: 1.3rem; letter-spacing: 0.3em; height: var(--tap); }
.dots { display: flex; gap: 8px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--hairline); border: 1px solid var(--text-3); }
.dots span.used { background: var(--danger); border-color: var(--danger); }
.lock-error { font-size: 0.85rem; color: var(--danger); min-height: 1.2em; text-align: center; }
.broken-title { font-size: 1.3rem; font-weight: 800; }

/* ---------- 레이아웃 ---------- */
.nav-title { font-weight: 900; font-size: 1.05rem; }
.nav-date { margin-left: auto; font-size: 0.85rem; color: var(--sub); font-variant-numeric: tabular-nums; }
.view { display: none; max-width: 560px; margin: 0 auto; padding: 4px 16px calc(var(--tab-h) + var(--safe-b) + 32px); }
.view.on { display: block; }
body.has-dock #view-workout { padding-bottom: calc(var(--tab-h) + var(--safe-b) + var(--dock-h, 190px) + 24px); }

.btn.big { height: var(--tap); font-size: 1.02rem; padding: 0 22px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.full { width: 100%; }
.card { background: var(--glass); border-radius: var(--radius); padding: 16px; }

.hero-stat { text-align: center; padding: 18px 0 14px; }
.hero-stat .cap { font-size: 0.78rem; font-weight: 600; color: var(--sub); letter-spacing: 0.02em; }
.hero-stat .num { font-size: 2.1rem; font-weight: 900; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.hero-stat .sub { font-size: 0.82rem; color: var(--sub); margin-top: 4px; min-height: 1.2em; }

.routine-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px; border-radius: var(--radius-sm); cursor: pointer; }
.routine-pick svg { color: var(--text-3); flex-shrink: 0; }
.routine-pick select { position: absolute; inset: 0; opacity: 0; width: 100%; font-size: 16px; cursor: pointer; }
.routine-pick:active { background: var(--glass); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 4px 10px; }
.lbl { font-size: 0.72rem; font-weight: 700; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- iOS 그룹 인셋 리스트 (design-reference 4번) ---------- */
.inset-group { background: var(--glass-strong); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border-card); }
.inset-group.gap { margin-top: 12px; }
.inset-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: var(--tap); position: relative; }
.inset-row + .inset-row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--hairline); }
.inset-row .row-label { font-size: 0.95rem; color: var(--text); flex-shrink: 0; min-width: 70px; }
.inset-row input, .inset-row select, .inset-row textarea {
  flex: 1; border: none; background: none; font-size: 1rem; color: var(--text);
  text-align: right; outline: none; min-width: 0; font-variant-numeric: tabular-nums;
}
.inset-row select { appearance: none; -webkit-appearance: none; padding-right: 18px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a8f99' d='M6 8L1.5 3.5l1-1L6 6l3.5-3.5 1 1z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center; text-align-last: right; }
.inset-row input::placeholder { color: var(--text-3); }
.inset-row.tappable { cursor: pointer; transition: background 0.12s; }
.inset-row.tappable:active { background: var(--glass); }
.inset-row > svg { color: var(--sub); flex-shrink: 0; }
.inset-row .val { margin-left: auto; color: var(--sub); font-size: 0.9rem; text-align: right; }
.stepper-row input { text-align: center; font-size: 1.25rem; font-weight: 700; }

.step {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-card);
  background: var(--glass); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; box-shadow: var(--highlight);
}
.step:active { transform: scale(0.94); background: var(--glass-strong); }
.step.big { width: 52px; height: 52px; }

details.more { margin: 12px 0; }
details.more summary { list-style: none; cursor: pointer; padding: 10px 4px; font-size: 0.88rem; color: var(--sub); font-weight: 600; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: ' ＋'; color: var(--text-3); }
details.more[open] summary::after { content: ' －'; }
#bd-save { margin-top: 4px; }

.seg { display: inline-flex; background: var(--glass); border: 1px solid var(--border-card); border-radius: 50px; padding: 3px; }
.seg button { font-size: 0.82rem; font-weight: 700; color: var(--sub); border: none; background: none; cursor: pointer; padding: 8px 14px; border-radius: 50px; transition: 0.2s; }
.seg button.on { background: #1d1d1f; color: #fff; }
body.dark .seg button.on { background: #f5f5f7; color: #1d1d1f; }
.seg-row { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.chart-card { padding: 12px 10px 8px; }
.chart-box { position: relative; height: 230px; }
.chart-note { font-size: 0.75rem; color: var(--text-3); text-align: center; padding-top: 6px; min-height: 1em; }
.empty { text-align: center; color: var(--text-3); font-size: 0.9rem; padding: 28px 12px; }

.icon-action {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--sub); flex-shrink: 0;
}
.icon-action:active { background: var(--glass); color: var(--text); }
.icon-action.danger { color: #ef4444; }

/* ---------- 운동 카드 ---------- */
.ex { margin-bottom: 12px; padding: 14px 14px 8px; }
.ex-head { display: flex; align-items: flex-start; gap: 8px; }
.ex-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }
.ex-meta { font-size: 0.8rem; color: var(--sub); margin-top: 2px; font-variant-numeric: tabular-nums; }
.ex-prev { font-size: 0.8rem; color: var(--text-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 0.68rem; font-weight: 700; color: var(--sub); border: 1px solid var(--hairline); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: 2px; }
.ex-count { margin-left: auto; font-size: 0.82rem; font-weight: 700; color: var(--sub); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 2px; }
.ex-count.complete { color: var(--success); }

.ss-group { position: relative; padding-left: 14px; margin-bottom: 12px; }
.ss-group::before { content: ''; position: absolute; left: 3px; top: 26px; bottom: 14px; width: 3px; border-radius: 2px; background: var(--text-3); opacity: 0.5; }
.ss-label { font-size: 0.72rem; font-weight: 700; color: var(--text-3); letter-spacing: 0.06em; margin: 0 0 6px 2px; }

.bump { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--hairline); }
.bump svg { color: var(--text); flex-shrink: 0; }
.bump-text { flex: 1; font-size: 0.85rem; line-height: 1.35; }
.bump-text b { font-variant-numeric: tabular-nums; }

.sets { margin-top: 8px; }
.set {
  display: grid; grid-template-columns: 30px 1fr 1fr 48px; align-items: center; gap: 6px;
  min-height: var(--tap); padding: 0 4px 0 8px; border-radius: var(--radius-sm); cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.set + .set { margin-top: 2px; }
.set.active { background: var(--accent-light); box-shadow: inset 0 0 0 1.5px var(--accent); }
.set-no { font-size: 0.82rem; font-weight: 800; color: var(--text-3); text-align: center; }
.set.warm .set-no { font-size: 0.72rem; }
.set-w, .set-r { font-size: 1.08rem; font-weight: 700; }
.set-w small, .set-r small { font-size: 0.75rem; color: var(--sub); font-weight: 600; margin-left: 2px; }
.set.warm .set-w, .set.warm .set-r { color: var(--sub); font-weight: 600; }
.set.done .set-w, .set.done .set-r { color: var(--sub); }
.set .hit { color: var(--success); }
.chk {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--text-3); background: none;
  display: inline-flex; align-items: center; justify-content: center; color: transparent; cursor: pointer; justify-self: end;
}
.set.done .chk { background: var(--success); border-color: var(--success); color: #fff; }
.ex-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 4px; }
.wk-foot { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- 도크 (현재 세트 + 휴식) ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 150;
  padding: 10px 16px 12px; background: var(--glass-strong);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--hairline);
}
.dock > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.dock-title { font-size: 0.85rem; font-weight: 700; color: var(--sub); text-align: center; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-title b { color: var(--text); }
.dock-steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 2px; background: var(--glass-strong); border: 1px solid var(--border-card); border-radius: 30px; padding: 3px; }
.stepper .step { border: none; box-shadow: none; background: transparent; }
.step-val { flex: 1; display: flex; align-items: baseline; justify-content: center; min-width: 0; }
.step-val input { width: 100%; min-width: 0; border: none; background: none; outline: none; text-align: right; font-size: 1.45rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; padding: 0; -moz-appearance: textfield; }
.step-val input::-webkit-outer-spin-button, .step-val input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-unit { font-size: 0.75rem; font-weight: 600; color: var(--sub); margin-left: 2px; flex-shrink: 0; width: 1.6em; }

.rest { margin-bottom: 10px; }
.rest-bar { height: 4px; border-radius: 2px; background: var(--hairline); overflow: hidden; margin-bottom: 6px; }
#rest-fill { height: 100%; width: 100%; background: var(--accent); transform-origin: left; }
.rest-row { display: flex; align-items: center; gap: 8px; }
.rest-label { font-size: 0.82rem; font-weight: 700; color: var(--sub); }
.rest-time { font-size: 1.7rem; font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-right: auto; }
.rest.over .rest-time { color: var(--accent); }
.rest .btn.sm { height: 40px; min-width: 52px; }
@keyframes flash { 0%, 100% { background: var(--glass-strong); } 50% { background: var(--accent-light); } }
.dock.flash { animation: flash 0.5s ease 4; }

/* ---------- 탭바 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 160; display: flex;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--hairline);
}
.tabbar button { flex: 1; border: none; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.7rem; font-weight: 700; color: var(--text-3); }
.tabbar button.on { color: var(--accent); }

/* ---------- 시트(모달) ---------- */
.sheet { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg-elevated); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 18px 16px calc(18px + var(--safe-b)); box-shadow: var(--shadow-lg);
}
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.sheet-title { font-weight: 900; font-size: 1.15rem; flex: 1; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.sheet .inset-group { background: var(--surface-2); }
.list-item { display: flex; align-items: center; gap: 2px; padding: 6px 4px 6px 14px; min-height: var(--tap); }
.list-item + .list-item { border-top: 1px solid var(--hairline); }
.list-item .name { flex: 1; min-width: 0; }
.list-item .icon-action { width: 36px; height: 40px; }
.list-item .name div:first-child { font-weight: 700; font-size: 0.95rem; }
.list-item .name div + div { font-size: 0.78rem; color: var(--sub); }
textarea.json { width: 100%; min-height: 240px; border-radius: var(--radius-sm); border: 1px solid var(--border-card); background: var(--surface-2); color: var(--text); padding: 12px; font: 0.8rem/1.5 'SF Mono', Consolas, monospace; resize: vertical; }
.toggle { width: 44px; height: 26px; }

.toast { bottom: calc(var(--tab-h) + var(--safe-b) + 16px); }
body.has-dock .toast { bottom: calc(var(--tab-h) + var(--safe-b) + var(--dock-h, 190px) + 12px); }

@media (min-width: 420px) { .set { grid-template-columns: 36px 1fr 1fr 52px; } }

.toast { white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }

/* ---------- 루틴 선택 ---------- */
#wk-picker { padding-top: 6px; }
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card.pick, .card.resume {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; cursor: pointer; padding: 16px; min-height: 132px; font: inherit; color: var(--text);
}
.card.pick:active, .card.resume:active { transform: scale(0.98); }
.card.pick.sug { box-shadow: var(--highlight), var(--shadow), inset 0 0 0 2px var(--text); }
.pick-code { font-size: 2.2rem; font-weight: 900; letter-spacing: -0.04em; line-height: 1; margin-bottom: 6px; }
.pick-name { font-size: 1rem; font-weight: 800; letter-spacing: -0.02em; }
.pick-meta { font-size: 0.8rem; color: var(--sub); }
.pick-last { font-size: 0.8rem; color: var(--text-3); margin-top: auto; padding-top: 6px; font-variant-numeric: tabular-nums; }
.pick-tag { position: absolute; top: 12px; right: 12px; font-size: 0.68rem; font-weight: 800; background: #1d1d1f; color: #fff; border-radius: 20px; padding: 3px 8px; }
body.dark .pick-tag { background: #f5f5f7; color: #1d1d1f; }
.card.resume { flex-direction: row; align-items: center; gap: 14px; min-height: 0; width: 100%; margin-top: 8px; }
.card.resume .pick-code { margin: 0; }
.resume-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.resume-name { font-size: 1.05rem; font-weight: 800; }
.card.resume .pick-last { margin: 0; padding: 0; }
.card.resume > svg { color: var(--text-3); }

/* ---------- 세션 상단 ---------- */
.sess-bar { display: flex; align-items: center; gap: 4px; margin: 4px -8px 6px; }
.sess-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sess-title b { font-size: 1.1rem; font-weight: 900; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-title span { font-size: 0.8rem; color: var(--sub); font-variant-numeric: tabular-nums; }
#wk-finish { height: 40px; }

.ex-strip { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 2px 16px 4px; scroll-behavior: smooth; }
.ex-strip::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px; height: 40px; padding: 0 12px;
  border-radius: 20px; border: 1px solid var(--border-card); background: var(--glass); cursor: pointer;
  font-size: 0.82rem; font-weight: 700; color: var(--sub);
}
.chip span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip small { font-size: 0.72rem; font-variant-numeric: tabular-nums; opacity: 0.8; }
.chip.on { background: #1d1d1f; color: #fff; border-color: transparent; }
body.dark .chip.on { background: #f5f5f7; color: #1d1d1f; }
.chip.done svg { color: var(--success); }
.chip.on.done svg { color: inherit; }

.page-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.page-nav .btn:disabled { opacity: 0.35; }

/* ---------- 지난 기록 ---------- */
.hist {
  display: block; width: 100%; text-align: left; margin: 10px 0 2px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--hairline); font: inherit; color: inherit; cursor: pointer;
}
.hist:disabled { cursor: default; }
.hist-row { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; line-height: 1.9; font-variant-numeric: tabular-nums; }
.hist-row.muted { color: var(--text-3); }
.hist-date { color: var(--text-3); font-weight: 700; min-width: 42px; }
.hist-sets { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.hist-row:first-child .hist-sets { font-weight: 800; }
.hist-up { color: var(--success); flex-shrink: 0; }
.hist-more { display: flex; align-items: center; justify-content: flex-end; gap: 2px; font-size: 0.75rem; color: var(--text-3); font-weight: 700; margin-top: 2px; }
.hist-full { padding: 12px 16px; }
.hist-full + .hist-full { border-top: 1px solid var(--hairline); }
.hf-top { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.hf-top .tag { margin-left: 0; vertical-align: 0; }
.hf-1rm { margin-left: auto; font-size: 0.8rem; color: var(--sub); }
.hf-sets { font-size: 0.9rem; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- 끝내기 요약 ---------- */
.sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 8px 0 4px; }
.sum-num { font-size: 1.8rem; font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.sum-cap { font-size: 0.75rem; color: var(--sub); font-weight: 600; }
.sheet-note { font-size: 0.8rem; color: var(--text-3); text-align: center; margin-top: 12px; }
.ex-note { font-size: 0.76rem; color: var(--text-3); margin-top: 2px; }
