:root {
  --bg: #0d1117;
  --card: #161b22;
  --card2: #1d242d;
  --line: #28303a;
  --text: #e6edf3;
  --mute: #8b96a3;
  --accent: #4ade80;
  --accent-ink: #06210f;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --tab-h: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  overscroll-behavior-y: contain;
}
#view { max-width: 560px; margin: 0 auto; padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top)); }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--mute); font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; cursor: pointer;
}
button:active { filter: brightness(1.25); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; color: var(--mute); padding: 6px 8px; }
button.small { padding: 5px 10px; font-size: 13px; }
input, select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.daysel select { appearance: none; -webkit-appearance: none; text-align: center; text-align-last: center; padding: 10px 0; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); padding: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mute { color: var(--mute); }
.small-text { font-size: 13px; }
.big { font-size: 28px; font-weight: 800; line-height: 1.1; }
.accent { color: var(--accent); }
.warn { color: var(--warn); }
.neg { color: var(--danger); }
.gap { height: 8px; }

/* 하단 탭 */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; border: 0; border-radius: 0; background: none; height: var(--tab-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--mute); font-size: 12px; padding: 0;
}
nav.tabs button .ic { font-size: 20px; line-height: 1; }
nav.tabs button.on { color: var(--accent); font-weight: 700; }

/* 날짜 막대 */
.datebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.datebar .label { font-weight: 700; font-size: 17px; text-align: center; flex: 1; }

/* 세그먼트 */
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 8px; border-radius: 8px; color: var(--mute); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* 진행 바 */
.bar { margin: 10px 0; }
.bar .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar .track { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar .fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }
.bar.over .fill { background: var(--warn); }
.bar.thin .track { height: 6px; }

/* 출석 점 */
.dots { display: flex; gap: 8px; }
.dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; }
.dot.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 800; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card2); border-radius: 12px; padding: 10px; text-align: center; }
.stat .v { font-size: 20px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--mute); }

/* 운동 */
.ex-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ex-name { font-size: 17px; font-weight: 700; }
.ex-meta { font-size: 13px; color: var(--mute); }
.last-line { font-size: 13px; color: var(--mute); margin: 6px 0; }
.badge { display: inline-block; font-size: 13px; padding: 4px 10px; border-radius: 99px; background: rgba(74,222,128,.15); color: var(--accent); font-weight: 700; margin: 4px 0; }
.badge.done { background: var(--accent); color: var(--accent-ink); }
.setrow { display: grid; grid-template-columns: 28px 1fr 18px 1fr 74px; gap: 6px; align-items: center; margin: 6px 0; }
.setrow .n { color: var(--mute); text-align: center; font-weight: 700; }
.setrow .x { text-align: center; color: var(--mute); }
.setrow .prev { font-size: 12px; color: var(--mute); text-align: right; white-space: nowrap; }
.setrow input { text-align: center; font-size: 17px; font-weight: 700; padding: 10px 4px; }
.setrow .unit { font-size: 11px; color: var(--mute); text-align: center; grid-column: 2; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--mute); margin-left: 6px; vertical-align: middle; }
.tag.main { color: var(--accent); border-color: var(--accent); }

/* 식단 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border-radius: 99px; font-size: 14px; }
.chip small { color: var(--mute); margin-left: 4px; }
.meal { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.meal:first-of-type { border-top: 0; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { padding: 4px 10px; }
.qty span { min-width: 34px; text-align: center; font-weight: 700; }

/* 입력 폼 */
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--mute); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 7px 4px; text-align: right; border-top: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t th { color: var(--mute); font-weight: 600; border-top: 0; font-size: 12px; }

.exrow { padding: 10px 0; border-top: 1px solid var(--line); }
.exrow:first-of-type { border-top: 0; }

/* 시트 */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
}
.sheet .sheet-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 700; font-size: 17px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%); background: #000c; color: #fff; padding: 9px 16px; border-radius: 99px;
  z-index: 60; font-size: 14px; pointer-events: none; opacity: 0; transition: opacity .2s;
}
#toast.show { opacity: 1; }

svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--mute); font-size: 10px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--mute); margin-top: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.empty { text-align: center; color: var(--mute); padding: 18px 0; font-size: 14px; }
.notice { background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.4); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
