:root {
  --rose: #d98a9e;
  --rose-deep: #b15c74;
  --cream: #fcf6f3;
  --ink: #3a2c30;
  --gold: #e6b860;
  --gold-bright: #ffd479;
  --ok: #7bc47f;
  --shadow: rgba(58, 28, 38, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Noto Sans KR', system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 30% 20%, #fdeef0 0%, #f6e4e8 40%, #efd7e0 100%);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  word-break: keep-all;      /* 한국어를 어절 단위로 줄바꿈 (단어 중간 깨짐 방지) */
  overflow-wrap: break-word; /* 단, 끊을 수 없는 긴 토큰은 강제 줄바꿈 */
}

#app { position: fixed; inset: 0; }

/* 언어 토글 */
.lang-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 14px var(--shadow);
  transition: background 0.15s ease;
}
.lang-toggle:hover { background: #fff; }

/* 도움말 버튼 */
.help-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 20;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 14px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.help-btn:hover { background: #fff; }

/* 링크 복사 버튼 (물음표 오른쪽) */
.copy-link-btn {
  position: fixed;
  top: 14px;
  left: 54px;
  z-index: 20;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  appearance: none;
  cursor: pointer;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 14px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.copy-link-btn:hover { background: #fff; }
.copy-link-btn svg { width: 16px; height: 16px; }

/* 토스트 알림 */
.toast {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  max-width: 84%;
  text-align: center;
  color: #fff;
  background: rgba(28, 18, 22, 0.92);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.toast.show { animation: toastPop 2s ease forwards; }
@keyframes toastPop {
  0%   { opacity: 0; transform: translate(-50%, 8px); }
  12%  { opacity: 1; transform: translate(-50%, 0); }
  85%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -4px); }
}

/* 도움말 팝업 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(40, 24, 30, 0.5);
  backdrop-filter: blur(4px);
}
.modal-card {
  width: min(440px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px var(--shadow);
  text-align: left;
}
.modal-title {
  font-family: 'Cormorant Garamond', 'Noto Sans KR', serif;
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  margin-bottom: 22px;
}
.tips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 26px;
}
.tips li {
  font-size: 14px;
  line-height: 1.6;
  color: #5c4a50;
}
.modal .primary-btn { display: block; margin: 0 auto; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.hidden { display: none !important; }

/* ---------- 시작 / 오류 카드 ---------- */
.start-card {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 24px 60px var(--shadow);
}

.kicker {
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--rose-deep);
  font-weight: 700;
  margin-bottom: 14px;
}

.title {
  font-family: 'Cormorant Garamond', 'Noto Sans KR', serif;
  font-size: 46px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin-bottom: 14px;
}
.title.small { font-size: 30px; }

.subtitle {
  font-size: 15px;
  line-height: 1.7;
  color: #6c585e;
  margin-bottom: 28px;
}

.primary-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  padding: 16px 44px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--rose) 0%, var(--rose-deep) 100%);
  box-shadow: 0 10px 24px rgba(177, 92, 116, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(177, 92, 116, 0.5); }
.primary-btn:active { transform: translateY(0); }

.injury-note {
  margin-top: 16px;
  font-size: 12.5px;
  line-height: 1.55;
  font-weight: 500;
  color: #a8632a;
  background: rgba(230, 184, 96, 0.16);
  border-radius: 12px;
  padding: 10px 14px;
}
.tips li.tip-warn {
  font-weight: 700;
  color: #a8632a;
  background: rgba(230, 184, 96, 0.16);
  border-radius: 10px;
  padding: 10px 12px;
}
/* 부상 경고의 강제 줄바꿈은 모바일에서만 (데스크톱은 띄어쓰기로 자연스럽게) */
.injury-note br,
.tips li.tip-warn br { display: none; }

.privacy-note {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  background: rgba(217, 138, 158, 0.12);
  border-radius: 16px;
  padding: 16px 18px;
}
.privacy-note .lock { font-size: 20px; line-height: 1.4; }
.privacy-note p { font-size: 12.5px; line-height: 1.65; color: #6c585e; }
.privacy-note b { color: var(--rose-deep); }

/* 수요 투표 */
.vote-zone { margin-top: 22px; }
.ghost-btn {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--rose-deep);
  background: transparent;
  border: 1.5px solid rgba(177, 92, 116, 0.45);
  padding: 11px 24px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ghost-btn:hover:not(:disabled) { background: rgba(217, 138, 158, 0.14); }
.share-btn {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.share-icon { width: 16px; height: 16px; }
.ghost-btn:disabled { cursor: default; opacity: 0.85; }
.ghost-btn.voted { color: var(--ok); border-color: rgba(123, 196, 127, 0.6); }
.vote-count {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
  color: #6c585e;
}

/* 푸터용 컴팩트 변형 */
.ghost-btn-sm {
  margin-top: 0;
  padding: 6px 14px;
  font-size: 12.5px;
}
.footer-note .vote-count { margin-top: 0; }

/* ---------- 로딩 ---------- */
.spinner {
  width: 52px; height: 52px;
  border: 4px solid rgba(177, 92, 116, 0.2);
  border-top-color: var(--rose-deep);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 22px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; color: #6c585e; }

/* ---------- 측정 화면 ---------- */
#stage-screen { padding: 0; justify-content: flex-start; }

#stage {
  position: relative;
  width: 100%;
  flex: 1;
  overflow: hidden;
  background: #1c1216;
}

#video { display: none; }

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 각도 readout */
.readout {
  position: absolute;
  top: 58px;
  left: 22px;
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}
.angle-block { display: flex; align-items: baseline; color: #fff; }
.angle-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 84px;
  font-weight: 600;
  line-height: 0.9;
  transition: color 0.25s ease;
}
.angle-unit { font-size: 40px; font-weight: 600; margin-left: 4px; }
.angle-label {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.02em;
}
.knee-badge {
  margin-top: 10px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: #1c1216;
  background: var(--ok);
  padding: 5px 12px;
  border-radius: 999px;
}
.knee-badge.warn { background: var(--gold); color: #4a3208; }

/* 목표 달성 상태 */
.readout.goal-met .angle-value { color: var(--gold-bright); }

.goal-banner {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-size: 16px;
  font-weight: 700;
  color: #5a3d12;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(230, 184, 96, 0.5);
  animation: pop 0.35s ease;
}
@keyframes pop {
  0% { transform: translateX(-50%) scale(0.7); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* 카메라 전환 버튼 */
.flip-btn {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  appearance: none;
  cursor: pointer;
  color: #fff;
  background: rgba(28, 18, 22, 0.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.12s ease;
}
.flip-btn:hover { background: rgba(28, 18, 22, 0.78); }
.flip-btn:active { transform: translateX(-50%) scale(0.94); }
.flip-btn svg { width: 27px; height: 27px; }

/* 측정 기록 패널 (다중 세션) */
.records {
  position: absolute;
  top: 58px;
  right: 18px;
  z-index: 5;
  width: 232px;
  max-height: calc(100% - 80px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #fff;
}
.records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.records-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.88);
}
.add-btn {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: #5a3d12;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  border: none;
  box-shadow: 0 4px 14px rgba(230, 184, 96, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}
.add-btn:hover { transform: scale(1.08); }
.add-btn:active { transform: scale(1); }

.session-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 2px;
}
.session-card {
  background: rgba(28, 18, 22, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.session-card.active {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 1px var(--gold-bright);
}
.card-head { display: flex; align-items: center; gap: 8px; }
.session-name {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  padding: 2px 0;
}
.session-name:focus { border-bottom-color: var(--gold-bright); }
.session-name::placeholder { color: rgba(255, 255, 255, 0.4); }
.icon-btn {
  appearance: none;
  cursor: pointer;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 5px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  transition: color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }
.icon-btn svg { width: 100%; height: 100%; }
.card-body { display: flex; flex-direction: column; gap: 4px; }
.rec-row { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; }
.rec-leg { font-size: 13px; color: rgba(255, 255, 255, 0.82); }
.rec-val { font-family: 'Cormorant Garamond', serif; font-size: 28px; font-weight: 600; line-height: 1; }
.card-remeasure {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 7px 0;
  transition: background 0.15s ease;
}
.card-remeasure:hover { background: rgba(255, 255, 255, 0.22); }

/* 데벨로페 성공 플래시 */
.develop-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 7;
  font-size: 28px;
  font-weight: 700;
  color: #5a3d12;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  padding: 14px 32px;
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(230, 184, 96, 0.55);
  pointer-events: none;
}
.develop-flash.show { animation: developPop 2.4s ease forwards; }
@keyframes developPop {
  0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  8%   { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
  78%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -64%) scale(1); opacity: 0; }
}

/* 컨트롤 */
.controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: center;
  width: calc(100% - 32px);
  max-width: 560px;
}
.control-group {
  background: rgba(28, 18, 22, 0.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.control-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.7);
}
.goal-control { flex: 1; min-width: 220px; }

.pill-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.pill-btn:hover { background: rgba(255, 255, 255, 0.22); }

.goal-row { display: flex; align-items: center; gap: 14px; }
.round-btn {
  appearance: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
}
.round-btn:hover { background: rgba(255, 255, 255, 0.24); }
.goal-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 30px;
  font-weight: 600;
  color: var(--gold-bright);
  min-width: 64px;
  text-align: center;
}
#goal-slider {
  width: 100%;
  accent-color: var(--gold);
  cursor: pointer;
}

.footer-note {
  width: 100%;
  font-size: 11.5px;
  color: #8a727a;
  padding: 10px 12px;
  background: var(--cream);
  display: flex;
  gap: 8px 14px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* 제작자 크레딧 / 인스타 링크 */
.credit {
  margin-top: 20px;
  font-size: 12.5px;
  color: #8a727a;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.ig-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--rose-deep);
  font-weight: 700;
  text-decoration: none;
}
.ig-link:hover { text-decoration: underline; }
.ig-icon { width: 15px; height: 15px; }

/* 모바일 */
@media (max-width: 520px) {
  .angle-value { font-size: 60px; }
  .angle-unit { font-size: 28px; }
  .title { font-size: 38px; }

  /* 측정 화면: 글 줄이고 카메라를 넓힘.
     푸터는 투표 버튼만 — 개인정보 문구·인스타·카운트는 시작 화면에 있으므로 모바일에선 숨김 */
  .footer-note { padding: 7px 10px; gap: 6px 12px; }
  .footer-note > span[data-i18n="footer"],
  .footer-note .ig-link,
  .footer-note .js-vote-count { display: none; }
  .ghost-btn-sm { padding: 6px 14px; font-size: 12px; }

  /* 안내·각도 영역이 우측 기록 패널 밑으로 깔리지 않게 폭 제한 */
  .readout { max-width: calc(100% - 180px); }

  /* 기록 패널 조금 더 컴팩트하게 */
  .records { top: 50px; right: 10px; width: 158px; max-height: calc(100% - 58px); padding: 12px; gap: 8px; }
  .records-title { font-size: 12px; }
  .rec-val { font-size: 22px; }
  .rec-leg { font-size: 12px; }

  .injury-note br,
  .tips li.tip-warn br { display: inline; }
}
