:root {
  --bg: #0f1420;
  --panel: #1a2233;
  --panel-2: #212b40;
  --line: #2c3852;
  --text: #e8edf7;
  --muted: #94a3bf;
  --accent: #4fd1a5;
  --accent-2: #6ea8ff;
  --warn: #ffb454;
  --danger: #ff7a7a;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  min-height: 100vh;
}
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px;
  background: rgba(15,20,32,.92);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}
.brand { font-size: 1.25rem; font-weight: 800; letter-spacing: -.5px; }
.tabs { display: flex; gap: 6px; flex: 1; }
.tab {
  background: none; border: 1px solid transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  font-size: .95rem; font-weight: 600; transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--accent); border-color: var(--line); }
.streak-badge {
  background: linear-gradient(135deg, #2a1f10, #3a2a12);
  border: 1px solid #5a4020; color: var(--warn);
  padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: .95rem;
}

main { max-width: 980px; margin: 0 auto; padding: 26px 18px 80px; }
.view { display: none; }
.view.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

h2 { font-size: 1.35rem; margin-bottom: 6px; letter-spacing: -.4px; }
.sub { color: var(--muted); margin-bottom: 22px; font-size: .95rem; line-height: 1.5; }

.banner {
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px;
  font-size: .98rem; line-height: 1.55; border: 1px solid;
}
.banner.info { background: #14243a; border-color: #24457a; color: #bcd4ff; }
.banner.success { background: #102b22; border-color: #1f5c46; color: #a9f0d5; }
.banner.warn { background: #2f2411; border-color: #6a4d1d; color: #ffd9a0; }
.banner .banner-title { font-weight: 800; margin-bottom: 4px; }
.banner button { margin-top: 10px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}
.card h3 { font-size: 1.08rem; margin-bottom: 4px; }

.part-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.chip.lv1, .chip.lv2 { color: var(--danger); border-color: #5c2f2f; background: #2a1717; }
.chip.lv3 { color: var(--warn); border-color: #5a4020; background: #2a2011; }
.chip.lv4, .chip.lv5 { color: var(--accent); border-color: #1f5c46; background: #10281f; }
.chip.tier { color: var(--accent-2); border-color: #2a4a7a; background: #14243a; }

.stretch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.stretch {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.stretch:hover {
  border-color: #3d5279;
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(3, 9, 20, .28);
}
.stretch.guide-clickable { cursor: pointer; }
.stretch.guide-clickable:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 3px;
  border-color: var(--accent);
}
.stretch .pict {
  aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center;
  background: #0b1322;
  border: 1px solid rgba(116, 147, 196, .16);
  border-radius: 13px; padding: 0; overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035), 0 8px 24px rgba(5,10,20,.2);
}
.stretch .pose-img {
  width: 100%; height: 100%; display: block; object-fit: cover;
  transition: transform .35s ease, filter .35s ease;
}
.stretch:hover .pose-img { transform: scale(1.025); filter: brightness(1.04); }
.stretch .s-name { font-weight: 800; font-size: 1rem; }
.stretch ol { padding-left: 18px; color: var(--muted); font-size: .88rem; line-height: 1.55; }
.stretch .dose { color: var(--accent); font-weight: 700; font-size: .88rem; }
.stretch .caution { color: var(--warn); font-size: .82rem; line-height: 1.4; }
.stretch a.video {
  color: var(--accent-2); font-size: .85rem; text-decoration: none; font-weight: 600;
}
.stretch a.video:hover { text-decoration: underline; }

.check-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line);
}
.check-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; }
.check-label input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }

.btn {
  background: var(--accent); color: #08281c; border: none; font-weight: 800;
  padding: 12px 22px; border-radius: 10px; cursor: pointer; font-size: 1rem;
  transition: transform .1s, filter .15s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 8px 16px; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.save-bar { position: sticky; bottom: 18px; display: flex; justify-content: center; margin-top: 10px; }

/* 진단 */
.test-card .howto { color: var(--muted); font-size: .9rem; line-height: 1.6; padding-left: 18px; margin: 10px 0; }
.test-meta { color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.input-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.input-row label { font-size: .9rem; color: var(--muted); }
.input-row input[type=number] {
  background: #0e1524; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 10px 12px; width: 110px; font-size: 1rem;
}
.input-row input[type=range] { flex: 1; min-width: 160px; accent-color: var(--accent); }
.grade-preview { font-weight: 800; min-width: 90px; }

/* 기록 */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-align: center;
}
.stat .num { font-size: 1.7rem; font-weight: 900; color: var(--accent); }
.stat .lab { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.chart-wrap { overflow-x: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: .85rem; color: var(--muted); }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
table.hist { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.hist th, table.hist td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.hist th { color: var(--muted); font-weight: 600; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-width: 340px; }
.cal .dow { text-align: center; color: var(--muted); font-size: .75rem; padding: 2px; }
.cal .day {
  aspect-ratio: 1; border-radius: 6px; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; color: var(--muted); border: 1px solid transparent;
}
.cal .day.done { background: #14503a; color: #a9f0d5; font-weight: 700; }
.cal .day.today { border-color: var(--accent-2); }
.cal .day.empty { background: none; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--accent);
  padding: 14px 22px; border-radius: 12px; font-weight: 700;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 100; max-width: 90vw;
}
.hidden { display: none !important; }

.modal {
  position: fixed; inset: 0; background: rgba(5,8,15,.7); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 30px; max-width: 480px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  max-height: calc(100vh - 40px); overflow-y: auto;
}
.modal-card .big { font-size: 3rem; margin-bottom: 10px; }
.modal-card h3 { font-size: 1.2rem; margin-bottom: 10px; }
.modal-card p { color: var(--muted); line-height: 1.6; margin-bottom: 18px; }

.result-list { text-align: left; margin: 14px 0 18px; }
.result-list .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 4px; border-bottom: 1px dashed var(--line); font-size: .95rem;
}

/* 영상 */
.video-row {
  display: flex; gap: 10px; align-items: center; cursor: pointer;
  background: #0e1524; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; transition: border-color .15s; width: 100%;
  color: inherit; font: inherit; text-align: left;
}
.video-row:hover { border-color: var(--accent-2); }
.video-thumb { width: 96px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.video-meta { min-width: 0; }
.video-title {
  color: var(--accent-2); font-size: .84rem; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.video-by { color: var(--muted); font-size: .76rem; margin-top: 3px; }
.embed-wrap { position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; }
.embed-wrap iframe, .embed-wrap video {
  position: absolute; inset: 0; width: 100%; height: 100%; background: #050a12;
}
.modal-card.wide { max-width: 640px; width: 100%; }

/* 타이머 */
.dose-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.t-btn.running { border-color: var(--accent); color: var(--accent); font-variant-numeric: tabular-nums; }

/* 재측정 게이트 진행바 */
.prog-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.prog-label { width: 74px; color: var(--muted); font-size: .9rem; flex-shrink: 0; }
.prog-bar { flex: 1; height: 10px; background: #0e1524; border-radius: 999px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--accent-2); border-radius: 999px; transition: width .3s; }
.prog-fill.ok { background: var(--accent); }
.prog-num { font-size: .85rem; color: var(--muted); min-width: 90px; text-align: right; }

/* 프로필 · 등급표 */
.profile-card { border-color: #2a4a7a; }
.radio-label { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: .95rem; cursor: pointer; }
.radio-label input { accent-color: var(--accent); width: 16px; height: 16px; }
#p-age {
  background: #0e1524; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 9px 12px; font-size: .95rem;
}
.grade-table { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.test-meta.source { margin: 6px 0 2px; font-size: .8rem; }

/* 스트레칭 사전 */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip.filter { cursor: pointer; background: var(--panel); font-size: .85rem; padding: 6px 13px; border: 1px solid var(--line); }
.chip.filter:hover { color: var(--text); border-color: var(--accent-2); }
.chip.filter.on { color: var(--accent); border-color: var(--accent); background: #10281f; }
.muscle-row { display: flex; gap: 5px; flex-wrap: wrap; }
.chip.muscle { color: #d0b8ff; border-color: #4a3a7a; background: #221a3a; }
.lib-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* 단계별 자세 · 자극 부위 가이드 */
.guide-btn {
  width: 100%; border: 1px solid #2f6a5a; background: linear-gradient(135deg, #102b22, #14243a);
  color: var(--text); border-radius: 10px; padding: 10px 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; font: inherit;
}
.guide-btn span { color: var(--muted); font-size: .78rem; }
.guide-btn strong { color: var(--accent); font-size: .86rem; }
.guide-btn:hover { border-color: var(--accent); }
.guide-content { text-align: left; }
.guide-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.guide-head h3 { margin: 2px 0 0; }
.eyebrow { color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.guide-stages {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  padding-bottom: 4px;
}
.guide-stage, .target-figure {
  background: #0e1524; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.guide-stage img {
  display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: contain;
  background: #08111f;
}
.guide-stage figcaption, .target-figure figcaption { display: grid; gap: 5px; padding: 10px; }
.guide-stage figcaption strong { color: var(--text); font-size: .84rem; }
.guide-stage figcaption span, .target-figure figcaption span { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.target-section { margin-top: 22px; }
.target-section > .eyebrow { margin-bottom: 8px; }
.target-figure { display: grid; grid-template-columns: minmax(180px, 42%) 1fr; align-items: center; }
.target-figure img { width: 100%; max-height: 430px; object-fit: cover; display: block; }
.chip.target-chip { color: #ffd19c; border-color: #86451f; background: #3a2112; }
.guide-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0 10px; }
.guide-meta > div { display: grid; gap: 4px; padding: 10px; background: #0e1524; border: 1px solid var(--line); border-radius: 10px; }
.guide-meta strong, .contra-section h4, .source-section h4 { font-size: .82rem; color: var(--text); }
.guide-meta span { color: var(--muted); font-size: .82rem; }
.guide-caution { padding: 10px 12px; border: 1px solid #6a4d1d; background: #2f2411; border-radius: 10px; }
.contra-section, .source-section { margin-top: 14px; }
.contra-section ul, .source-section ul { padding-left: 18px; margin-top: 7px; color: var(--muted); font-size: .8rem; line-height: 1.55; }
.source-section a { color: var(--accent-2); }
.medical-note { color: var(--muted); font-size: .75rem; line-height: 1.45; margin: 16px 0 12px !important; }

/* 변화량 배지 */
.delta { font-size: .78rem; font-weight: 800; padding: 2px 7px; border-radius: 999px; }
.delta.up { color: var(--accent); background: #10281f; }
.delta.down { color: var(--danger); background: #2a1717; }
.delta.same { color: var(--muted); background: var(--panel-2); }

@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 10px 12px; }
  .tabs { order: 3; flex: 1 1 100%; justify-content: space-between; }
  .tab { padding: 7px 10px; font-size: .85rem; }
  .modal { padding: 10px; align-items: flex-start; }
  .modal-card { padding: 18px; max-height: calc(100vh - 20px); }
  .guide-stages { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(210px, 78vw); overflow-x: auto; scroll-snap-type: x mandatory; }
  .guide-stage { scroll-snap-align: start; }
  .target-figure { grid-template-columns: 1fr; }
  .target-figure img { max-height: 520px; }
  .guide-meta { grid-template-columns: 1fr; }
}
