:root {
  --bg: #F5F4EF; --ink: #18181B; --accent: #C8313E; --muted: #52525B; --line: #71717A;
  --z1: #E4E4E7; --z2: #2459C9; --z3: #1E9E58; --z4: #E8840C; --z5: #C8313E;
  --card: #FFFFFF; --soft: #EBEAE4; --rule: #D4D4D8;
  --radius: 14px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "NanumSquare Neo", "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  padding-bottom: env(safe-area-inset-bottom);
}
.num, .big, .vdot-num, input, .axis, .mark-label { font-variant-numeric: tabular-nums; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 8px; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

a { color: var(--z2); text-underline-offset: 2px; }

/* 헤더 */
.site-header { padding: 20px 0 12px; }
.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
.sub { margin: 4px 0 0; color: var(--muted); }
.handle { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--ink); font-weight: 700; font-size: 0.9rem; }

/* 카드·블록 */
.card { background: var(--card); border-radius: var(--radius); padding: 18px 14px; box-shadow: 0 1px 0 var(--rule); }
.block { margin-top: 28px; }
.block h2 { font-size: 1.3rem; margin: 0 0 10px; }
.block h3 { font-size: 1.05rem; margin: 22px 0 8px; }
.block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.block-head h2 { margin: 0; }

/* 입력 */
.field { margin: 0 0 18px; }
.field:last-child { margin-bottom: 0; }
fieldset.field { border: 0; padding: 0; min-width: 0; }
label, legend { display: block; font-weight: 700; margin-bottom: 6px; padding: 0; }
.label-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 6px; }
.label-row label { margin: 0; }
.opt { font-weight: 400; color: var(--muted); font-size: 0.875rem; margin-left: 4px; }
input, select {
  font: inherit; font-size: 1.125rem; color: var(--ink);
  min-height: 48px; padding: 8px 12px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
  width: 100%; max-width: 100%;
}
#age { max-width: 140px; }
.input-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.input-row input { width: 140px; flex: none; }
.unit { color: var(--muted); }
input[aria-invalid="true"] { border-color: var(--accent); border-width: 2px; }
.help { margin: 6px 0 0; color: var(--muted); font-size: 0.9375rem; }
.help.small, .small { font-size: 0.875rem; }
.msg { margin: 8px 0 0; font-size: 0.9375rem; }
.msg.err { color: var(--accent); font-weight: 700; }
.msg.warn { color: var(--ink); background: #FFF4E5; border-left: 4px solid var(--z4); padding: 8px 10px; border-radius: 6px; }
.msg.note { color: var(--ink); background: var(--soft); padding: 10px 12px; border-radius: 8px; }
.icon { display: inline-block; width: 1.2em; text-align: center; }
.race-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.race-row select { width: auto; min-width: 78px; padding: 8px 6px; }
.hms { display: inline-flex; align-items: center; gap: 3px; }
.hms input { width: 46px; text-align: center; padding: 8px 2px; }

.btn, .btn-ghost {
  font: inherit; font-size: 0.9375rem; min-height: 44px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
}
.btn { background: var(--ink); color: #fff; border: 0; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost[aria-disabled="true"] { color: var(--muted); border-style: dashed; cursor: not-allowed; }

/* 기준 토글 */
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 12px; overflow: hidden; background: #fff; }
.seg button { font: inherit; font-size: 0.9375rem; min-height: 44px; padding: 6px 12px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 700; }
.seg button[aria-pressed="true"]::before { content: "✓ "; }
.seg button[aria-disabled="true"] { color: var(--muted); cursor: not-allowed; background: var(--soft); }
#basis-hint { margin: 6px 0 0; text-align: right; }

/* 배지 */
.badge-slot { display: inline-flex; }
.badge-wrap { display: inline-flex; vertical-align: middle; }
.badge {
  position: relative;
  font: inherit; font-size: 0.75rem; font-weight: 700; line-height: 1;
  padding: 5px 8px; margin: 2px 2px; border-radius: 999px; background: #fff; cursor: pointer;
  white-space: nowrap;
}
.badge::after { content: ""; position: absolute; inset: -9px -3px; } /* 터치 영역 확장 */
.badge.research { border: 1.5px solid #3F3F46; color: #3F3F46; }
.badge.suggest { border: 1.5px solid var(--accent); color: var(--accent); }

.sheet {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20;
  width: min(688px, calc(100% - 32px));
  background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 12px;
  font-size: 0.9375rem; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.sheet strong { color: #fff; margin-right: 4px; }

/* 존 막대 */
.bar-wrap { margin: 14px 0 6px; }
.marks { position: relative; height: 52px; }
.mark { position: absolute; bottom: 0; width: 0; }
.mark::after { content: ""; position: absolute; left: -1px; bottom: -4px; width: 2px; background: var(--ink); }
.mark.row0::after { height: 34px; }
.mark.row1::after { height: 14px; }
.mark-label { position: absolute; white-space: nowrap; font-size: 0.8125rem; font-weight: 700; line-height: 1.2; }
.mark.row0 .mark-label { bottom: 34px; }
.mark.row1 .mark-label { bottom: 14px; }
.mark.center .mark-label { transform: translateX(-50%); }
.mark.left .mark-label { left: -1px; }
.mark.right .mark-label { right: -1px; }
.bar { display: flex; height: 36px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.seg-z { display: flex; align-items: center; justify-content: center; min-width: 0; font-size: 0.8125rem; font-weight: 800; }
.seg-z span { overflow: hidden; }
.seg-z + .seg-z { border-left: 1px solid rgba(24,24,27,.35); }
.seg-z.blank { background: repeating-linear-gradient(45deg, transparent 0 4px, rgba(113,113,122,.18) 4px 6px); }
.axis { display: flex; justify-content: space-between; font-size: 0.8125rem; color: var(--muted); margin-top: 4px; }

/* 존 색 + 글자 대비(10장) */
.z1 { background: var(--z1); color: #18181B; }
.z2 { background: var(--z2); color: #FFFFFF; }
.z3 { background: var(--z3); color: #18181B; }
.z4 { background: var(--z4); color: #18181B; }
.z5 { background: var(--z5); color: #FFFFFF; }

.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 26px; padding: 0 6px; margin-right: 6px; border-radius: 6px;
  font-size: 0.8125rem; font-weight: 800; vertical-align: middle;
}
.chip.z1 { border: 1px solid var(--line); }

/* 표 */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
caption { text-align: left; font-size: 0.875rem; color: var(--muted); padding: 0 0 6px; caption-side: top; }
th, td { text-align: left; vertical-align: middle; padding: 10px 8px; border-bottom: 1px solid var(--rule); font-size: 0.9375rem; }
thead th { font-size: 0.8125rem; color: var(--muted); font-weight: 700; background: var(--soft); }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 700; }
.zt tbody th { white-space: nowrap; }
.zname { display: block; font-size: 0.8125rem; font-weight: 400; color: var(--muted); margin-top: 4px; white-space: normal; }
.num { white-space: nowrap; }
.big { font-weight: 800; font-size: 1.0625rem; }
.pct { display: block; font-size: 0.8125rem; color: var(--muted); }
tr.is-input > * { background: #FFF8E1; }
.code { display: inline-block; min-width: 1.4em; font-weight: 800; }
td.num .badge-wrap { margin-left: 2px; }
.pt td.num { white-space: normal; }
.pt td.nowrap { white-space: nowrap; }
abbr[title] { text-decoration: none; }

.lt-line, .src-line { font-size: 0.9375rem; margin: 10px 0 0; }
.src-line { color: var(--muted); }
.empty { background: var(--card); border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 22px 16px; color: var(--muted); text-align: center; margin: 10px 0 0; }

/* 펼침 */
details.more { margin-top: 12px; }
details.more > summary {
  cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 6px;
  list-style: none; color: var(--ink);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; display: inline-block; transition: transform .15s; }
details.more[open] > summary::before { transform: rotate(90deg); }
.more-body { padding: 2px 0 4px; }
.more-body p { margin: 8px 0; font-size: 0.9375rem; }

/* 세션 카드 */
.cards { display: grid; gap: 12px; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
.session { background: var(--card); border-radius: var(--radius); padding: 14px 14px 6px; border-top: 6px solid var(--z1); }
.session.z1-edge { border-top-color: var(--line); }
.session.z2-edge { border-top-color: var(--z2); }
.session.z3-edge { border-top-color: var(--z3); }
.session.z4-edge { border-top-color: var(--z4); }
.session.z5-edge { border-top-color: var(--z5); }
.session h3 { margin: 0 0 8px; font-size: 1.0625rem; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.session dl { margin: 0; }
.session dl > div { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.session dt { font-size: 0.8125rem; color: var(--muted); font-weight: 700; }
.session dd { margin: 2px 0 0; }
.extra { display: block; font-size: 0.875rem; color: var(--muted); margin-top: 2px; }
.muted { color: var(--muted); }

/* 레이스 */
.vdot { background: var(--card); border-radius: var(--radius); padding: 14px; }
.vdot-label { font-weight: 800; margin-right: 8px; }
.vdot-num { font-size: 2rem; font-weight: 800; vertical-align: middle; }

/* 가민 비교 */
#garmin details.more { margin-top: 0; background: var(--card); border-radius: var(--radius); padding: 4px 14px 10px; }
#garmin summary { font-size: 1.125rem; }
.cmp { position: relative; margin: 8px 0 14px; }
.callout-row { height: 40px; align-items: stretch; }
.cmp-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cmp-name { flex: none; width: 64px; font-size: 0.8125rem; font-weight: 700; }
.cmp-track { position: relative; flex: 1; min-width: 0; }
.cmp-row .axis { flex: 1; margin: 0; }
.cmp-bar { display: flex; height: 30px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.cmp-hl { position: absolute; top: -4px; bottom: -4px; border: 3px solid var(--ink); border-radius: 6px; pointer-events: none; }
.cmp-hl.o { border-style: dashed; }
.cmp-callout {
  position: absolute; top: 0; transform: translateX(-50%);
  font-size: 0.8125rem; font-weight: 800; white-space: nowrap;
}
.cmp-callout::after { content: ""; position: absolute; left: calc(50% - 1px); top: 20px; width: 2px; height: 22px; background: var(--ink); }
.lead { font-weight: 700; }

/* 하단 */
.about { margin-top: 36px; }
.disclaimers, .sources { padding-left: 1.3em; margin: 0; }
.disclaimers li { margin: 0 0 10px; }
.sources li { margin: 0 0 8px; font-size: 0.875rem; color: var(--muted); }
.sources a { display: inline-flex; align-items: center; min-height: 24px; }
.data-row { margin-top: 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.data-row .help { margin: 0; }
.site-footer { padding: 28px 16px 40px; color: var(--muted); font-size: 0.875rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

[hidden] { display: none !important; }
