/* 레이아웃: 한 줄기 로그북. 오늘 체크 → 최근 5주 → 누적 → 앞으로 4주 → 설정 */
/* fonts:start 직접 포함한 글꼴 (아티팩트 빌드는 이 블록을 빼고 Google Fonts를 씁니다) */
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-600.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-700.woff2) format('woff2'); }
@font-face { font-family: 'Noto Sans KR'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/noto-sans-kr-400.woff2) format('woff2'); }
@font-face { font-family: 'Noto Sans KR'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/noto-sans-kr-500.woff2) format('woff2'); }
@font-face { font-family: 'Noto Sans KR'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/noto-sans-kr-700.woff2) format('woff2'); }
/* fonts:end */
:root {
  --bg: #F1F4F2;
  --surface: #FAFBFA;
  --fg: #16221D;
  --muted: #5C6B65;
  --line: #D3DCD7;
  --accent: #1F7A5C;
  --accent-soft: #DDEEE6;
  --on-accent: #FFFFFF;
  --warn: #8A5200;
  --warn-soft: #F6E7CC;
  --err: #B3261E;
  --font-body: 'Noto Sans KR', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-num: 'Barlow Condensed', 'Arial Narrow', 'Noto Sans KR', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1613; --surface: #16201C; --fg: #E5EEE9; --muted: #93A69D; --line: #28372F;
    --accent: #4DC49A; --accent-soft: #17382C; --on-accent: #081A12;
    --warn: #E3AE5A; --warn-soft: #3A2C12; --err: #FF8A80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1613; --surface: #16201C; --fg: #E5EEE9; --muted: #93A69D; --line: #28372F;
  --accent: #4DC49A; --accent-soft: #17382C; --on-accent: #081A12;
  --warn: #E3AE5A; --warn-soft: #3A2C12; --err: #FF8A80;
  color-scheme: dark;
}

/* 단독 실행(GitHub Pages)일 때만 기본 리셋과 안전 영역 */
.standalone { -webkit-text-size-adjust: 100%; }
.standalone body { margin: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
[hidden] { display: none !important; }

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px 48px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wrap > * { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
#today { display: flex; flex-direction: column; gap: 8px; }

/* 머리말: 날짜와 주차를 한 줄에, 진행 막대 아래 */
.headline { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.eyebrow { margin: 0; flex: none; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
h1 { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 700; }
.prog { display: flex; align-items: center; gap: 12px; }
.segs { display: flex; gap: 4px; flex: 1; }
.segs i { display: block; flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.segs i.on { background: var(--accent); }
.progtext { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.progtext.all { color: var(--accent); font-weight: 700; }
.note { margin: 8px 0 0; font-size: 13px; }
.warn { color: var(--warn); }
.back { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; padding: 4px 6px 4px 12px; border: 1px dashed var(--line); border-radius: 10px; }
.link { border: 0; background: none; color: var(--accent); font-weight: 700; font-size: 13px; padding: 8px 6px; cursor: pointer; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); line-height: 1.6; }

/* 오늘 체크: 종목마다 (이름·목표 | 완료) / (개수 −5 −1 [ ] +1 +5 × 세트 − [ ] +) 두 줄. 3종목이 한 화면에 들어옴 */
.rows { display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "info check" "ctrl ctrl"; gap: 6px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.row.done { background: var(--accent-soft); border-color: var(--accent); }
.info { grid-area: info; min-width: 0; }
.name { margin: 0; font-size: 15px; line-height: 20px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal { margin: 0; display: flex; align-items: baseline; gap: 4px; min-width: 0; flex-wrap: wrap; }
.goal .label { font-size: 11px; color: var(--muted); }
.goal .num { font-family: var(--font-num); font-size: 28px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.goal .unit { font-size: 13px; color: var(--muted); }
.goal .sets { font-family: var(--font-num); font-size: 20px; line-height: 28px; font-weight: 700; color: var(--accent); }
.check { grid-area: check; width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--accent); background: transparent; color: var(--on-accent); display: grid; place-items: center; cursor: pointer; padding: 0; touch-action: manipulation; }
.check svg { width: 26px; height: 26px; opacity: 0; }
.row.done .check { background: var(--accent); }
.row.done .check svg { opacity: 1; }
button:disabled, input:disabled, select:disabled { opacity: 0.45; cursor: default; }
.ctrl { grid-area: ctrl; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.times { color: var(--muted); font-size: 14px; }
.stepper { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.stepper button { width: 46px; height: 40px; padding: 0; border: 0; background: transparent; font-size: 22px; font-weight: 700; color: var(--accent); line-height: 1; cursor: pointer; touch-action: manipulation; -webkit-touch-callout: none; font-variant-numeric: tabular-nums; }
.stepper button:active:not(:disabled) { background: var(--accent-soft); }
.stepper.setstep button { width: 38px; }
.stepper input[type="number"] { min-width: 0; width: 56px; height: 40px; padding: 0; text-align: center; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: transparent; font-family: var(--font-num); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; border-radius: 0; }
.stepper.setstep input[type="number"] { width: 34px; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.delta { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta.over { color: var(--accent); font-weight: 700; }
@media (max-width: 360px) {
  .row { gap: 6px 8px; padding: 10px; }
  .stepper button { width: 40px; }
  .stepper.setstep button { width: 32px; }
  .stepper input[type="number"] { width: 46px; }
  .stepper.setstep input[type="number"] { width: 28px; }
  .goal .label { display: none; }
}
.empty { margin: 0; padding: 20px 16px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 14px; }

.status { margin: 0; min-height: 14px; line-height: 14px; font-size: 12px; color: var(--muted); }
.status.err { color: var(--err); }

/* 공통 섹션 */
.sec { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.sub { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
section { min-width: 0; }

/* 달력 */
.cal-head, .cal-row { display: grid; grid-template-columns: 34px repeat(7, minmax(0, 1fr)); gap: 4px; align-items: center; }
.cal-head { font-size: 11px; color: var(--muted); text-align: center; margin-bottom: 2px; }
.cal-row + .cal-row { margin-top: 4px; }
.wk { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cell { min-width: 0; height: 42px; border: 1px solid transparent; border-radius: 10px; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0; cursor: pointer; touch-action: manipulation; }
.cell .dn { font-size: 13px; line-height: 1; font-variant-numeric: tabular-nums; }
.cell .pips { display: flex; gap: 3px; }
.cell .pips i { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--line); }
.cell .pips i.on { background: var(--accent); }
.cell .frac { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cell.full .dn { color: var(--accent); font-weight: 700; }
.cell.today { border-color: var(--muted); }
.cell.sel { background: var(--accent-soft); border-color: var(--accent); }
.cell.pre { background: transparent; }
.cell:disabled { opacity: 0.35; }

/* 正 누적 */
.glyphs { display: flex; flex-wrap: wrap; gap: 6px 4px; align-items: center; }
.glyphs svg { width: 30px; height: 30px; }
.glyphs .on { stroke: var(--accent); }
.glyphs .off { stroke: var(--line); }
.glyphs .more { color: var(--muted); margin-right: 4px; }
.tallytext { margin: 10px 0 0; font-size: 14px; }
.tallytext b { font-variant-numeric: tabular-nums; }
.totals { margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px 8px; }
.totals div { min-width: 0; }
.totals dt { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.totals dd { margin: 0; font-family: var(--font-num); font-size: 30px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
.totals dd small { font-family: var(--font-body); font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.totals dd.best { margin-top: 2px; font-family: var(--font-body); font-size: 12px; line-height: 1.4; font-weight: 400; color: var(--muted); }
#dateLabel:focus:not(:focus-visible) { outline: none; }

/* 앞으로 4주 */
.tblwrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
td.n, th.n { text-align: right; }
td.n { font-family: var(--font-num); font-size: 20px; font-weight: 600; }
tr.cur td { background: var(--accent-soft); }

/* 설정 */
details.block { border-top: 1px solid var(--line); padding-top: 4px; }
details summary { cursor: pointer; font-weight: 700; font-size: 15px; min-height: 40px; display: flex; align-items: center; }
.set-body { margin: 8px 0 12px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, legend { font-size: 13px; color: var(--muted); padding: 0; }
.field.inline, .inline { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.inline label { font-size: 13px; color: var(--muted); }
.radio { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 36px; color: var(--fg); }
.radio input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
input[type="date"], input[type="number"], input:not([type]), select, textarea {
  min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 10px; font-size: 16px;
}
textarea { height: auto; padding: 10px; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; resize: vertical; width: 100%; }
input[type="file"] { font-size: 13px; max-width: 100%; min-width: 0; flex: 1; }
.sub-h { margin: 4px 0 0; font-size: 14px; font-weight: 700; }

.exlist { display: flex; flex-direction: column; gap: 10px; }
.exitem { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.exitem.off { opacity: 0.6; }
.exrow1 { display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: 8px; }
.exrow1 input { width: 100%; font-weight: 700; }
.exrow2 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.exrow2 label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.exrow2 input { width: 100%; }
.exrow3 { display: flex; align-items: center; gap: 6px; }
.spacer { flex: 1; }
.icon { min-width: 40px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; padding: 0 10px; font-size: 14px; }
.icon.danger { color: var(--err); }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px dashed var(--accent); background: transparent; color: var(--accent); font-size: 14px; cursor: pointer; }

.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { height: 44px; padding: 0 20px; border: 0; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 15px; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.errors { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--err); font-size: 13px; }
.confirm { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.confirm p { margin: 0; font-size: 14px; }

@media (prefers-reduced-motion: no-preference) {
  .row, .check, .segs i, .cell { transition: background-color 0.18s, border-color 0.18s; }
}

/* 달력: 쉬는 요일, 목표 주차 시작 */
.cell.rest:not(.sel) { background: transparent; border-color: var(--line); border-style: dashed; }
.cell.wkstart { box-shadow: inset 3px 0 0 var(--accent); }
.restdays { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.restdays .radio { min-height: 40px; }
.backup-note { flex-wrap: nowrap; }
.backup-note > span:first-child { min-width: 0; }
.backup-note .link { padding: 8px 8px; }

/* 세트 */
td.n small { font-family: var(--font-body); font-size: 12px; font-weight: 400; color: var(--muted); }

/* 종목별 꾸준함 */
.perex { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.perex li { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "head head" "bar pct"; gap: 6px 10px; align-items: center; }
.pe-head { grid-area: head; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.pe-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-meta { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pe-meta b { color: var(--fg); }
.pe-bar { grid-area: bar; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.pe-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.pe-pct { grid-area: pct; min-width: 40px; text-align: right; font-family: var(--font-num); font-size: 20px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.glyphs { margin-top: 14px; }

/* 한 줄 휴식 타이머 */
.timer { display: flex; align-items: center; gap: 6px; height: 46px; padding: 0 8px 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.timer .tlabel { font-size: 12px; color: var(--muted); }
.timer .time { flex: 1; min-width: 0; text-align: center; font-family: var(--font-num); font-size: 30px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.running .time { color: var(--accent); }
.timer .tstep { width: 44px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--accent); font-size: 13px; font-weight: 700; cursor: pointer; touch-action: manipulation; font-variant-numeric: tabular-nums; }
.timer .tgo { min-width: 64px; height: 36px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.timer .tgo.stop { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .timer.done { animation: timer-flash 0.5s ease-in-out 6; }
}
@keyframes timer-flash { 50% { background: var(--accent-soft); border-color: var(--accent); } }
.timer.done { border-color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 초 단위 운동의 시간 재기 버튼 */
.watch { flex: none; min-width: 44px; height: 40px; padding: 0 8px; border: 1px solid var(--accent); border-radius: 10px; background: transparent; color: var(--accent); font-size: 13px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.watch.stop { background: var(--accent); color: var(--on-accent); }
.row.timing .stepper.reps input { color: var(--accent); }
@media (max-width: 360px) { .watch { min-width: 38px; padding: 0 4px; } }

/* 운동 스톱워치 */
.work { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wtime { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wtime.running { font-family: var(--font-num); font-size: 24px; line-height: 1; font-weight: 700; color: var(--accent); }
.wbtn { flex: none; min-width: 72px; height: 36px; padding: 0 12px; border: 1px solid var(--accent); border-radius: 10px; background: transparent; color: var(--accent); font-size: 14px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.wbtn.stop { background: var(--accent); color: var(--on-accent); }
