/* ══════════════════════════════════════════════════
   GymLog · Notion 화이트 톤
   흰 배경 / 얇은 회색 선 / 그림자 최소 / 넉넉한 여백
   헬스장에서 쓰는 앱이라 터치 타깃은 크게 유지
   ══════════════════════════════════════════════════ */

:root{
  --bg:        #ffffff;
  --bg-2:      #fbfbfa;   /* 살짝 뜬 패널 */
  --bg-3:      #f1f1ef;   /* 입력칸 / 호버 */
  --line:      #e9e9e7;
  --line-2:    #dcdcd9;
  --txt:       #37352f;   /* Notion 본문색 */
  --txt-2:     #787774;
  --txt-3:     #9b9a97;
  --accent:    #2383e2;
  --red:       #e03e3e;
  --green:     #0f7b6c;
  --warn:      #d9730d;
  --shadow:    rgba(15,15,15,.04) 0 0 0 1px, rgba(15,15,15,.06) 0 2px 5px;
  --radius:    8px;
  --tabbar-h:  56px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --safe-t:    env(safe-area-inset-top, 0px);
}

*,*::before,*::after{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0; background:var(--bg); color:var(--txt);
  font-family:"Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
              "Apple SD Gothic Neo", "Segoe UI", system-ui, sans-serif;
  font-size:15px; line-height:1.5;
  -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior-y:none;
}
button{ font:inherit; color:inherit; background:none; border:none; cursor:pointer; }
input,select,textarea{ font:inherit; color:inherit; }
h1,h2,h3{ margin:0; font-weight:600; letter-spacing:-.01em; }
svg{ width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8;
     stroke-linecap:round; stroke-linejoin:round; }

/* ── 레이아웃 ─────────────────────────────── */
#app{ height:100dvh; display:flex; flex-direction:column; background:var(--bg); }
.view{ flex:1; min-height:0; display:flex; flex-direction:column; }
.view[hidden]{ display:none; }

.topbar{
  display:flex; align-items:flex-end; justify-content:space-between; gap:12px;
  padding:calc(var(--safe-t) + 16px) 20px 13px;
  background:var(--bg); border-bottom:1px solid var(--line);
  position:sticky; top:0; z-index:5;
}
.topbar-title{ font-size:23px; font-weight:700; }
.topbar-sub{ font-size:12.5px; color:var(--txt-2); font-weight:500; }

.scroll{
  flex:1; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch;
  padding:16px 16px calc(var(--tabbar-h) + var(--safe-b) + 88px);
}

/* ── 하단 탭바 ─────────────────────────────── */
.tabbar{
  display:flex; background:rgba(255,255,255,.94); backdrop-filter:blur(14px);
  border-top:1px solid var(--line);
  padding-bottom:var(--safe-b);
  position:fixed; left:0; right:0; bottom:0; z-index:20;
}
.tab{
  flex:1; height:var(--tabbar-h);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  color:var(--txt-3); font-size:10.5px; font-weight:600;
  transition:color .15s;
}
.tab svg{ width:20px; height:20px; }
.tab.is-active{ color:var(--txt); }

/* ── 공통 부품 ─────────────────────────────── */
.icon-btn{
  padding:7px 13px; border-radius:6px; background:var(--bg);
  border:1px solid var(--line-2); font-size:13.5px; font-weight:600; color:var(--txt);
}
.icon-btn:active{ background:var(--bg-3); }
.icon-btn.primary{ background:var(--txt); color:#fff; border-color:var(--txt); }

.card{
  background:var(--bg); border:1px solid var(--line);
  border-radius:var(--radius); margin-bottom:11px; overflow:hidden;
}
.card-head{
  display:flex; align-items:center; gap:9px;
  padding:12px 13px; border-bottom:1px solid var(--line); background:var(--bg-2);
}
.card-head h3{ font-size:15px; flex:1; min-width:0; font-weight:600;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* 종목명 + 그 아래 지난 기록 한 줄 */
.ch-main{ flex:1; min-width:0; }
.ch-main h3{ flex:none; }
.ch-sub{
  font-size:11.5px; color:var(--txt-3); margin-top:1px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.ch-sub b{ color:var(--txt-2); font-weight:700; }

.badge{
  flex:none; padding:2.5px 8px; border-radius:4px;
  font-size:11px; font-weight:600; letter-spacing:0;
  background:var(--bg-3); color:var(--txt-2);
}

.btn{
  display:flex; align-items:center; justify-content:center; gap:7px;
  width:100%; padding:13px; border-radius:7px;
  background:var(--txt); color:#fff; font-size:15px; font-weight:600;
}
.btn:active{ opacity:.82; }
.btn.ghost{ background:var(--bg); color:var(--txt); border:1px solid var(--line-2); }
.btn.ghost:active{ background:var(--bg-3); }
.btn.danger{ background:var(--bg); color:var(--red); border:1px solid var(--line-2); }
.btn.sm{ padding:9px; font-size:13.5px; }

.empty{ text-align:center; padding:56px 24px; color:var(--txt-2); }
.empty h3{ font-size:16px; color:var(--txt); margin-bottom:7px; font-weight:600; }
.empty p{ margin:0 0 20px; font-size:13.5px; line-height:1.65; color:var(--txt-2); }

.section-label{
  font-size:11.5px; font-weight:600; color:var(--txt-3);
  letter-spacing:.02em; margin:22px 3px 8px;
}
.section-label:first-child{ margin-top:2px; }

/* ── 세트 입력 그리드 ─────────────────────────
   [세트] [이전기록] [kg] [회] [체크]                 */
.set-row{
  display:grid; grid-template-columns:32px 1fr 72px 60px 44px;
  align-items:center; gap:7px; padding:6px 12px;
}
.set-row + .set-row{ border-top:1px solid var(--line); }
.set-row.head{
  padding-top:9px; padding-bottom:6px; background:var(--bg);
  font-size:11px; font-weight:600; color:var(--txt-3);
}
.set-row.head span{ text-align:center; }
.set-row.head span:nth-child(2){ text-align:left; }

.set-no{ text-align:center; font-size:13.5px; font-weight:600; color:var(--txt-2); }
.set-no.warmup{ color:var(--warn); font-size:11px; }
.set-prev{ font-size:12px; color:var(--txt-3); overflow:hidden;
  text-overflow:ellipsis; white-space:nowrap; }

.set-row input{
  width:100%; padding:10px 6px; text-align:center;
  background:var(--bg-3); border:1px solid transparent; border-radius:6px;
  font-size:16px; font-weight:600;   /* 16px 미만이면 iOS가 화면을 확대함 */
}
.set-row input:focus{ outline:none; border-color:var(--accent); background:var(--bg); }
.set-row input::placeholder{ color:var(--txt-3); font-weight:400; }

.set-check{
  height:38px; border-radius:6px; background:var(--bg-3);
  display:flex; align-items:center; justify-content:center; color:var(--txt-3);
  border:1px solid transparent;
}
.set-check svg{ width:17px; height:17px; stroke-width:2.6; }
.set-row.done .set-check{ background:var(--green); color:#fff; }
.set-row.done input{ background:transparent; color:var(--txt-2); }

.card-actions{ display:flex; gap:7px; padding:9px 12px 11px; }

/* ── 휴식 타이머 바 ─────────────────────────── */
.rest-bar{
  position:fixed; left:10px; right:10px;
  bottom:calc(var(--tabbar-h) + var(--safe-b) + 10px);
  z-index:25; border-radius:9px; overflow:hidden;
  background:var(--bg); border:1px solid var(--line-2);
  box-shadow:rgba(15,15,15,.08) 0 4px 16px;
}
.rest-fill{
  position:absolute; inset:0 auto 0 0; width:100%;
  background:#eaf3fc; transition:width 1s linear;
}
.rest-bar.over .rest-fill{ background:#e9f5f2; }
.rest-inner{ position:relative; display:flex; align-items:center; gap:8px; padding:10px 12px; }
.rest-label{ font-size:12.5px; font-weight:600; color:var(--txt-2); }
.rest-time{ font-size:18px; font-weight:700; font-variant-numeric:tabular-nums;
  flex:1; letter-spacing:-.02em; }
.rest-bar.over .rest-time{ color:var(--green); }
.rest-btn{
  padding:6px 10px; border-radius:5px; background:var(--bg);
  border:1px solid var(--line-2); font-size:12.5px; font-weight:600;
}
.rest-skip{ background:var(--txt); color:#fff; border-color:var(--txt); }

/* ── 시트(모달) ─────────────────────────────── */
.sheet-backdrop{
  position:fixed; inset:0; z-index:40; background:rgba(15,15,15,.35);
  display:flex; align-items:flex-end;
}
.sheet-backdrop[hidden]{ display:none; }
.sheet{
  width:100%; max-height:88dvh; display:flex; flex-direction:column;
  background:var(--bg); border-radius:12px 12px 0 0;
  padding-bottom:var(--safe-b);
  animation:slideUp .22s cubic-bezier(.32,.72,0,1);
}
@keyframes slideUp{ from{ transform:translateY(100%);} to{ transform:translateY(0);} }
.sheet-grip{
  width:36px; height:4px; border-radius:99px; background:var(--line-2);
  margin:9px auto 3px; flex:none;
}
.sheet-head{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:8px 16px 12px; border-bottom:1px solid var(--line); flex:none;
}
.sheet-head h2{ font-size:17px; font-weight:600; }
.sheet-body{ overflow-y:auto; padding:14px 16px 24px; }

/* ── 폼 ─────────────────────────────────────── */
.field{ margin-bottom:14px; }
.field label{ display:block; font-size:12px; font-weight:600;
  color:var(--txt-2); margin-bottom:6px; }
.field input, .field select, .field textarea{
  width:100%; padding:11px 12px; border-radius:6px;
  background:var(--bg-3); border:1px solid transparent;
  font-size:16px; font-family:inherit;
}
.field input:focus, .field select:focus, .field textarea:focus{
  outline:none; border-color:var(--accent); background:var(--bg);
}
.field textarea{ min-height:76px; resize:vertical; line-height:1.55; }

.chips{ display:flex; flex-wrap:wrap; gap:6px; }
.chip{
  padding:9px 14px; border-radius:6px; background:var(--bg);
  border:1px solid var(--line-2); font-size:14px; font-weight:600; color:var(--txt-2);
}
.chip.on{ background:var(--txt); border-color:var(--txt); color:#fff; }

/* ── 리스트 행 ──────────────────────────────── */
.row{
  display:flex; align-items:center; gap:10px;
  padding:13px 14px; background:var(--bg);
  border:1px solid var(--line); border-radius:var(--radius); margin-bottom:7px;
  text-align:left; width:100%;
}
.row:active{ background:var(--bg-2); }
.row-main{ flex:1; min-width:0; }
.row-title{ font-size:14.5px; font-weight:600;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.row-sub{ font-size:12px; color:var(--txt-2); margin-top:2px; }
.row-right{ font-size:12.5px; color:var(--txt-3); flex:none; text-align:right; }

/* ══ 인체 모형도 (피로도) ═══════════════════════ */
.bm-card{ margin-bottom:14px; }
.bm-head{
  display:flex; align-items:center; gap:8px; width:100%; text-align:left;
  padding:12px 13px; background:var(--bg-2); border-bottom:1px solid var(--line);
}
.bm-head h3{ font-size:14.5px; font-weight:600; flex:none; }
.bm-sub{ flex:1; min-width:0; font-size:11.5px; color:var(--txt-3);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bm-chev{ flex:none; color:var(--txt-3); display:flex; transition:transform .2s; }
.bm-chev svg{ width:18px; height:18px; }
.bm-chev.open{ transform:rotate(180deg); }
.bm-body[hidden]{ display:none; }

.bm-figs{ display:flex; gap:6px; padding:14px 10px 6px; justify-content:center; }
.bm-col{ flex:1; max-width:150px; display:flex; flex-direction:column;
  align-items:center; gap:4px; }
.bm-col > span{ font-size:11px; font-weight:600; color:var(--txt-3); }
.bm-fig{ width:100%; height:auto; display:block; }

.bm-rows{ padding:6px 13px 13px; }
.bm-row{ display:flex; align-items:center; gap:8px; padding:5px 0; }
.bm-row + .bm-row{ border-top:1px solid var(--line); }
.bm-row i{ width:11px; height:11px; border-radius:3px; flex:none;
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.07); }
.bm-nm{ width:30px; flex:none; font-size:13px; font-weight:600; }
.bm-st{ flex:1; min-width:0; font-size:12px; color:var(--txt-2);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.bm-fa{ flex:none; font-size:11.5px; font-weight:600; color:var(--txt-3); }

/* ══ 달력 ══════════════════════════════════════ */
.cal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:2px 2px 14px;
}
.cal-title{ font-size:17px; font-weight:700; }
.cal-nav{ display:flex; gap:6px; }
.cal-nav button{
  width:32px; height:32px; border-radius:6px; border:1px solid var(--line-2);
  display:flex; align-items:center; justify-content:center; color:var(--txt-2);
}
.cal-nav button:active{ background:var(--bg-3); }
.cal-nav button:disabled{ opacity:.3; }

.cal-grid{ display:grid; grid-template-columns:repeat(7,1fr); gap:2px; }
.cal-dow{
  text-align:center; font-size:11px; font-weight:600; color:var(--txt-3);
  padding-bottom:6px;
}
.cal-dow.sun{ color:var(--red); }

.cal-cell{
  aspect-ratio:1; display:flex; align-items:center; justify-content:center;
  position:relative;
}
.cal-day{
  width:36px; height:36px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:14px; font-weight:500; color:var(--txt);
  font-variant-numeric:tabular-nums;
}
.cal-cell.other .cal-day{ color:#d4d4d1; }
.cal-cell.sun .cal-day{ color:var(--red); }
.cal-cell.sun.other .cal-day{ color:#f0c9c9; }

/* 운동한 날 = 빨간 동그라미 */
.cal-cell.has .cal-day{
  background:var(--red); color:#fff; font-weight:700;
}
.cal-cell.has:active .cal-day{ opacity:.75; }

/* 오늘 = 얇은 테두리 */
.cal-cell.today .cal-day{ box-shadow:inset 0 0 0 1.5px var(--txt); }
.cal-cell.today.has .cal-day{ box-shadow:inset 0 0 0 1.5px var(--txt), 0 0 0 2px #fff; }

.cal-legend{
  display:flex; align-items:center; gap:14px; justify-content:center;
  padding:14px 0 2px; font-size:11.5px; color:var(--txt-3);
}
.cal-legend i{ display:inline-block; width:11px; height:11px; border-radius:50%;
  margin-right:5px; vertical-align:-1px; }

/* ── 통계 ───────────────────────────────────── */
.stat-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:7px; margin-bottom:14px; }
.stat{ background:var(--bg); border:1px solid var(--line);
  border-radius:var(--radius); padding:12px 10px; text-align:center; }
.stat b{ display:block; font-size:19px; font-weight:700; letter-spacing:-.02em; }
.stat span{ font-size:11px; color:var(--txt-2); }

.chart{ width:100%; height:170px; display:block; }
.chart .grid{ stroke:var(--line); stroke-width:1; }
.chart .line{ fill:none; stroke:var(--accent); stroke-width:2.2; }
.chart .area{ fill:url(#g); }
.chart .dot{ fill:var(--accent); }
.chart text{ fill:var(--txt-3); font-size:10px; stroke:none;
  font-family:inherit; font-weight:500; }

.bar-row{ display:flex; align-items:center; gap:9px; margin-bottom:8px; }
.bar-row .nm{ width:34px; font-size:12.5px; font-weight:600; flex:none; color:var(--txt-2); }
.bar-track{ flex:1; height:20px; background:var(--bg-3); border-radius:4px; overflow:hidden; }
.bar-fill{ height:100%; border-radius:4px; transition:width .3s; }
.bar-row .vl{ width:40px; text-align:right; font-size:12.5px;
  color:var(--txt-2); font-variant-numeric:tabular-nums; flex:none; }

/* ── 토스트 ─────────────────────────────────── */
.toast{
  position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(var(--tabbar-h) + var(--safe-b) + 74px); z-index:50;
  background:var(--txt); color:#fff;
  padding:10px 17px; border-radius:7px; font-size:13.5px; font-weight:600;
  box-shadow:rgba(15,15,15,.14) 0 4px 14px;
}
.toast[hidden]{ display:none; }

.sync-note{
  font-size:11.5px; color:var(--txt-3); text-align:center;
  padding:12px 16px 4px; line-height:1.6;
}

/* ── PC에서 볼 때: 폰 크기로 가운데 정렬 ──────
   실제 폰(≤520px)에서는 아무 영향 없음                */
@media (min-width:521px){
  body{ background:#f7f7f5; }
  #app{
    width:414px; max-width:100%; height:min(896px, 100dvh);
    margin:max(0px, calc((100dvh - 896px)/2)) auto;
    position:relative; overflow:hidden;
    border:1px solid var(--line-2); border-radius:22px;
    box-shadow:rgba(15,15,15,.1) 0 12px 40px;
  }
  /* 아래 4개는 모두 #app 안에 있으므로 프레임 기준으로 붙습니다 */
  .tabbar, .rest-bar, .toast, .sheet-backdrop{ position:absolute; }
  .sheet-backdrop{ inset:0; }
}

/* 운동 시간 — 상단 고정 바에 표시되어 스크롤해도 계속 보임 */
.dur{ color:var(--txt-2); font-weight:700; }
.dur.live{ color:var(--red); }
.stat-grid.four{ grid-template-columns:repeat(4,1fr); }
.stat-grid.four .stat{ padding:12px 6px; }
.stat-grid.four .stat b{ font-size:17px; }
