@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
  --bg: #ffffff;
  --sub: #f6f6f3;
  --text: #191a17;
  --muted: #8a8b85;
  --line: #ececea;
  --accent: #6f8c1f;
  --accent-soft: #f2f5e8;
  --on-accent: #ffffff;
  --danger: #c4452f;
  --logo-ink: #1c2a1a;
  --logo-win: #2f4a16;
  --logo-swoosh: #7d9b2a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121311; --sub: #1c1d1a; --text: #ececea; --muted: #8e8f89;
    --line: #2a2b27; --accent: #a5c447; --accent-soft: #23281a; --on-accent: #121311;
    --logo-ink: #ececea; --logo-win: #a5c447; --logo-swoosh: #5f7a22;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px; line-height: 1.5; letter-spacing: -0.2px;
  font-variant-numeric: tabular-nums;
  word-break: keep-all; overflow-wrap: anywhere;
}
a { color: inherit; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }

/* ---------- 헤더 ---------- */
.head { display: flex; align-items: center; justify-content: space-between; height: 76px; }
.logo { display: block; text-decoration: none; line-height: 0; }
.logo-svg { width: 168px; height: auto; overflow: visible; }
.logo-svg text { font-family: "Arial Black", "Archivo Black", "Pretendard", sans-serif; font-weight: 900; }
.lg-t { fill: var(--logo-ink); font-size: 36px; }
.lg-a { fill: var(--logo-ink); font-size: 10px; font-family: Arial, sans-serif !important; font-weight: 700 !important; }
.lg-w { fill: var(--logo-win); font-size: 47px; }
.lg-s { fill: var(--logo-swoosh); }
.lg-b { fill: #e8902a; }
.me-link { font-size: 14px; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; max-width: 55%; }
.me-link b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-link.need { color: var(--accent); font-weight: 600; }

/* ---------- 월 ---------- */
.month { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 8px 0 14px; }
.month h1 { margin: 0; font-size: 20px; font-weight: 700; min-width: 128px; text-align: center; }
.month button {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg);
  color: var(--text); font-size: 16px; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.month button:disabled { opacity: .3; cursor: default; }

/* ---------- 탭 ---------- */
.tabs {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line);
}
.tabs button {
  font: inherit; font-size: 15px; padding: 12px 0; border: 0; background: none; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--text); font-weight: 700; border-bottom-color: var(--text); }
section { padding: 20px 0 48px; }

/* ---------- 순위 ---------- */
.summary { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.summary b { color: var(--text); font-weight: 600; }
.mybox {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border-radius: 12px; background: var(--accent-soft); margin-bottom: 8px; font-size: 15px;
}
.mybox strong { font-size: 18px; font-weight: 700; color: var(--accent); margin-left: 6px; }
ol.rank { list-style: none; margin: 0; padding: 0; }
ol.rank li {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 12px;
  padding: 14px 4px; border-bottom: 1px solid var(--line);
}
ol.rank li:last-child { border-bottom: 0; }
ol.rank li.me .nm b { color: var(--accent); }
.pos { font-weight: 700; font-size: 16px; color: var(--muted); text-align: center; }
.pos.top { color: var(--accent); }
.nm { min-width: 0; }
.nm b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm span { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.val { font-weight: 700; font-size: 17px; text-align: right; }
.val small { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 2px; }

/* ---------- 폼 ---------- */
.field { margin-bottom: 18px; }
.field > label, .lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
input[type=date], input[type=number], input[type=text], input[type=password] {
  width: 100%; font: inherit; font-size: 17px; padding: 12px 14px; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  -moz-appearance: textfield;
}
input.big { font-size: 26px; font-weight: 700; padding: 12px 14px; }
input::placeholder { color: color-mix(in srgb, var(--muted) 45%, var(--bg)); font-weight: 400; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn {
  display: block; width: 100%; font: inherit; font-size: 16px; font-weight: 700; text-align: center; text-decoration: none;
  padding: 14px; border: 0; border-radius: 10px; background: var(--accent); color: var(--on-accent); cursor: pointer;
}
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.quick button {
  font: inherit; font-size: clamp(12px, 3.6vw, 14px); font-weight: 600; padding: 8px 0; white-space: nowrap; letter-spacing: -.02em; border-radius: 8px;
  border: 1px solid var(--line); background: var(--sub); color: var(--text); cursor: pointer;
}
.quick button:active { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { display: inline-block; width: auto; font-size: 14px; padding: 11px 16px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.hint { font-size: 13px; color: var(--muted); text-align: center; margin: 12px 0 0; }
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-radius: 12px; background: var(--sub); font-size: 14px; margin-bottom: 18px;
}
.notice a { color: var(--accent); font-weight: 700; text-decoration: none; white-space: nowrap; }

/* ---------- 내 기록 ---------- */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.totals div { padding: 14px 16px; border-radius: 12px; background: var(--sub); }
.totals span { display: block; font-size: 13px; color: var(--muted); }
.totals b { font-size: 24px; font-weight: 700; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.cal .d {
  height: 52px; border: 0; background: none; padding: 4px 0 0; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.cal .d small { font-size: 10px; font-weight: 700; color: var(--accent); line-height: 1; }
.cal .d.on { background: var(--accent-soft); }
.cal .d.today > span { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.cal .d:disabled { color: var(--line); cursor: default; }
.cal .blank { height: 52px; }
.cal-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- 날짜 시트 ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,0); transition: background .2s; }
.sheet-bg.open { background: rgba(0,0,0,.35); }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: var(--bg);
  border-radius: 16px 16px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .2s ease-out;
}
.sheet-bg.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h3 { margin: 0; font-size: 18px; font-weight: 700; }
.sheet-head button { border: 0; background: none; font: inherit; font-size: 15px; color: var(--muted); cursor: pointer; padding: 6px; }
ul.recs { list-style: none; margin: 0 0 18px; padding: 0; }
ul.recs li { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
ul.recs li span { color: var(--muted); font-size: 13px; margin-right: 4px; }
ul.recs li b { font-weight: 600; margin-right: 14px; }
.del { border: 0; background: none; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; padding: 4px; }
.del:hover { color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 32px 0; font-size: 14px; }

/* ---------- 순위 → 회원 기록 ---------- */
ol.rank li.tap { cursor: pointer; grid-template-columns: 28px 1fr auto 10px; }
ol.rank li.tap::after { content: "›"; color: var(--muted); font-size: 18px; }
ol.rank li.tap:active { background: var(--sub); }
.cal .d.ro { cursor: default; }
.cal .d.future { color: var(--line); }
table.daytable { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 14px; }
table.daytable th, table.daytable td { padding: 10px 2px; border-bottom: 1px solid var(--line); text-align: right; }
table.daytable th { font-size: 12px; color: var(--muted); font-weight: 500; }
table.daytable th:first-child, table.daytable td:first-child { text-align: left; }

/* ---------- 칼로리·차트 ---------- */
:root { --c-swing: #6f8c1f; --c-rope: #3f7fd6; --c-kcal: #d4700f; }
@media (prefers-color-scheme: dark) { :root { --c-swing: #86a232; --c-rope: #4a8ae0; --c-kcal: #d9771a; } }
h3.sub { margin: 36px 0 12px; font-size: 17px; font-weight: 700; padding-top: 24px; border-top: 1px solid var(--line); }
h3.sub small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.hero-num { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; }
.hero-num b { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.hero-num span { font-size: 14px; color: var(--muted); }
table.kcal { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 18px; }
table.kcal th, table.kcal td { padding: 9px 2px; border-bottom: 1px solid var(--line); text-align: right; }
table.kcal th { font-size: 12px; color: var(--muted); font-weight: 500; }
table.kcal th:first-child, table.kcal td:first-child { text-align: left; }
i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
i.sw.swing { background: var(--c-swing); }
i.sw.rope { background: var(--c-rope); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; }
.legend .unit { margin-left: auto; }

.kcal-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.kcal-sum div { padding: 14px 16px; border-radius: 12px; background: var(--sub); }
.kcal-sum span { display: block; font-size: 13px; color: var(--muted); }
.kcal-sum b { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.kcal-sum b small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kcal-sum em { display: block; font-style: normal; font-size: 12px; color: var(--muted); }
.dchart .ct { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.dchart .ct small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 2px; }
.dsvg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.dsvg .gl { stroke: var(--line); stroke-width: 1; }
.dsvg .yl, .dsvg .xl { fill: var(--muted); font-size: 10px; font-family: inherit; }
.dsvg .kline { fill: none; stroke: var(--c-kcal); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dsvg .kdot { fill: var(--c-kcal); stroke: var(--bg); stroke-width: 2; opacity: 0; }
.dsvg .xh { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.dsvg .bs { fill: var(--c-swing); }
.dsvg .br { fill: var(--c-rope); }
.dsvg .dim { opacity: .35; }
.dsvg .hit { fill: transparent; cursor: crosshair; }
.dchart .legend { margin-bottom: 2px; }
.dchart .legend i.ln { display: inline-block; width: 14px; height: 2px; background: var(--c-kcal); margin-right: 6px; border-radius: 1px; }
.dchart .axes { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin: 6px 0 -4px; }
.dsvg .kline-halo { fill: none; stroke: var(--bg); stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; }
.dchart .tip { margin: 10px 0 0; font-size: 13px; color: var(--muted); min-height: 40px; line-height: 1.55; }
.dchart .tip b { color: var(--text); }

/* ---------- 이름 설정 ---------- */
ul.names { list-style: none; margin: 0; padding: 0; }
ul.names li button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 15px 4px;
  border: 0; border-bottom: 1px solid var(--line); background: none; font: inherit; font-size: 16px; color: var(--text); cursor: pointer; text-align: left;
}
ul.names li button.on { color: var(--accent); font-weight: 700; }
ul.names li button.on::after { content: "✓"; }
.reg { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.reg-q { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.reg-row { display: flex; gap: 8px; }
.reg-row input { flex: 1; min-width: 0; }
.reg-col { display: grid; gap: 8px; }

/* ---------- 토스트 ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(12px);
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; transition: .2s; pointer-events: none; max-width: calc(100% - 40px); z-index: 40;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); color: #fff; }

footer { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 0 32px; }
footer a { color: var(--muted); }

/* ---------- 관리자 ---------- */
.card { border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 14px; background: var(--bg); }
.card h2 { margin: 0 0 14px; font-size: 17px; font-weight: 700; }

/* ---------- 좁은 화면 (갤럭시 폴드 접은 화면 등) ---------- */
@media (max-width: 330px) {
  .wrap { padding: 0 14px; }
  .pair { grid-template-columns: 1fr; gap: 14px; }
  .totals, .kcal-sum { gap: 8px; }
  .totals div, .kcal-sum div { padding: 12px; }
  .totals b { font-size: 20px; }
  .kcal-sum b { font-size: 21px; }
  .logo-svg { width: 140px; }
  .month { gap: 10px; }
  .month h1 { font-size: 18px; min-width: 110px; }
  .val { font-size: 15px; }
  .cal .d { height: 46px; font-size: 13px; }
  .cal .d small { font-size: 9px; }
}
