/* ==========================================================================
   요가 웹앱 — 오디오 퍼스트 UI
   기술은 배경으로. 화면은 최소한만 말하고, 나머지는 소리가 한다.
   ========================================================================== */

:root {
  --sand:    #F4F1EA;
  --sand-2:  #EAE5DA;
  --ink:     #23231F;
  --ink-2:   #4A4A44;
  --muted:   #8A877D;
  --sage:    #7C8C77;
  --sage-2:  #9FAE99;
  --clay:    #B98E6F;
  --line:    #DCD6C9;
  --radius:  18px;
  --shadow:  0 1px 2px rgba(35,35,31,.04), 0 8px 28px rgba(35,35,31,.06);
  --ff: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--ff); background: var(--sand); color: var(--ink);
  -webkit-font-smoothing: antialiased; line-height: 1.55;
  transition: background .8s ease, color .8s ease;
}

/* ---------- 눈 감기 모드 ---------- */
body.eyes-closed {
  background: #0A0A09; color: #6E6B62;
}
body.eyes-closed .app-header,
body.eyes-closed .practice-meta,
body.eyes-closed .practice-controls,
body.eyes-closed .cam-panel,
body.eyes-closed .cue-list,
body.eyes-closed .stage figure { opacity: 0; pointer-events: none; }
body.eyes-closed .breath-orb { transform: scale(1.35); }
body.eyes-closed .eyes-exit { opacity: .5; }

.app { max-width: 1080px; margin: 0 auto; padding: 0 24px 80px; }

/* ---------- 헤더 ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 26px 0 18px; transition: opacity .6s ease;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 19px; font-weight: 650; margin: 0; letter-spacing: -.02em; }
.brand span { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.nav { display: flex; gap: 6px; }

/* ---------- 버튼 ---------- */
button { font-family: inherit; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .18s ease;
}
.btn:hover { border-color: var(--sage); color: var(--sage); }
.btn.primary {
  background: var(--ink); color: var(--sand); border-color: var(--ink);
  padding: 14px 30px; font-size: 15px; font-weight: 600;
}
.btn.primary:hover { background: var(--sage); border-color: var(--sage); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.btn[aria-pressed="true"] { background: var(--sage); border-color: var(--sage); color: #fff; }

/* ---------- 화면 전환 ---------- */
.screen { display: none; animation: fade .5s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 체크인 ---------- */
.lede { max-width: 620px; margin: 8px 0 34px; }
.lede h2 { font-size: 30px; font-weight: 660; letter-spacing: -.03em; margin: 0 0 10px; }
.lede p { color: var(--ink-2); margin: 0; font-size: 15px; }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.field { margin-bottom: 22px; }
.field:last-child { margin-bottom: 0; }
.field label { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 14px; font-weight: 560; margin-bottom: 10px; }
.field label em { font-style: normal; color: var(--sage); font-weight: 600; font-size: 13px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 7px; }

input[type=range] {
  -webkit-appearance: none; width: 100%; height: 4px; border-radius: 3px;
  background: linear-gradient(90deg, var(--sage-2), var(--sand-2)); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2px solid var(--sage); cursor: pointer;
  box-shadow: 0 2px 8px rgba(35,35,31,.14);
}
input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  border: 2px solid var(--sage); cursor: pointer;
}
.scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 9px 16px; font-size: 13.5px; cursor: pointer; transition: all .16s ease;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--sand); border-color: var(--ink); }

.toggles { display: flex; flex-wrap: wrap; gap: 10px; }

.actions { display: flex; gap: 12px; align-items: center; margin-top: 30px; }

/* ---------- 프리뷰 ---------- */
.rationale {
  border-left: 3px solid var(--sage); padding: 4px 0 4px 16px;
  color: var(--ink-2); font-size: 15px; margin: 0 0 26px;
}
.summary-row { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 26px; }
.stat { }
.stat b { display: block; font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.stat span { font-size: 12.5px; color: var(--muted); }

.seq-list { display: flex; flex-direction: column; gap: 2px; }
.seq-phase {
  font-size: 11.5px; letter-spacing: .1em; color: var(--muted);
  text-transform: uppercase; margin: 22px 0 8px;
}
.seq-item {
  display: grid; grid-template-columns: 58px 1fr auto; align-items: center;
  gap: 14px; padding: 9px 12px; border-radius: 12px; transition: background .16s;
}
.seq-item:hover { background: var(--sand-2); }
.seq-item .thumb { width: 52px; height: 52px; }
.seq-item .thumb svg, .seq-item .thumb img { width: 100%; height: 100%; display: block; }
.seq-item .nm { font-size: 14.5px; font-weight: 540; }
.seq-item .sa { font-size: 12px; color: var(--muted); }
.seq-item .dur { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 수련 화면 ---------- */
.practice { min-height: 78vh; display: flex; flex-direction: column; }
.practice-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; color: var(--muted); transition: opacity .6s ease;
}
.progress { height: 2px; background: var(--sand-2); border-radius: 2px; margin: 12px 0 0; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--sage); transition: width .4s ease; }

.stage {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 40px;
  align-items: center; padding: 26px 0;
}
@media (max-width: 900px) { .stage { grid-template-columns: minmax(0, 1fr); gap: 20px; } }

/* 오른쪽 열 — 호흡 오브 · 웹캠 교정 · 큐가 한 줄기로 쌓인다 */
.side-col {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  min-width: 0; width: 100%;
}

.stage figure { margin: 0; text-align: center; transition: opacity .6s ease; }
.pose-frame {
  background: var(--sand-2); border-radius: 24px; aspect-ratio: 1/1;
  max-width: 420px; margin: 0 auto; overflow: hidden; position: relative;
}
.pose-frame svg, .pose-frame img { width: 100%; height: 100%; display: block; }
/* 나노 바나나 출력이 정사각이 아니어도 잘리지 않게 — 프레임 배경(--sand-2)과 색이 같아 이음매가 안 보인다 */
.pose-photo { object-fit: contain; background: var(--sand-2); }
.pose-frame .skel .fig { stroke: var(--ink); }
.pose-frame .skel .head { fill: var(--ink); }
.pose-frame .skel .cap { fill: var(--ink); }
.pose-frame .skel .accent { stroke: var(--sage); stroke-width: 2.2; fill: none; }
.pose-frame .skel .floor { stroke: var(--line); stroke-width: 1.2; }
.frame-tag {
  position: absolute; z-index: 2; left: 14px; bottom: 12px; font-size: 10.5px;
  letter-spacing: .06em; color: var(--muted); background: rgba(255,255,255,.72);
  padding: 4px 9px; border-radius: 99px;
}

.pose-name { margin: 20px 0 2px; font-size: 27px; font-weight: 650; letter-spacing: -.03em; }
.pose-sa { color: var(--muted); font-size: 13.5px; font-style: italic; }
.pose-side { display: inline-block; margin-left: 8px; font-size: 12px; color: var(--clay);
  border: 1px solid var(--clay); border-radius: 99px; padding: 1px 9px; font-style: normal; }

/* 호흡 오브 */
.breath-wrap { display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; }
.breath-orb {
  width: 200px; height: 200px; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 50% 45%, var(--sage-2), var(--sage));
  opacity: .9; transition: transform 3s cubic-bezier(.37,0,.3,1), opacity .8s;
  display: grid; place-items: center;
}
.breath-orb.inhale { transform: scale(1.16); }
.breath-orb.exhale { transform: scale(.82); }
.breath-orb b { color: #fff; font-size: 15px; font-weight: 560; letter-spacing: .12em; }
.breath-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.cue-list { list-style: none; padding: 0; margin: 0; max-width: 340px; transition: opacity .6s; }
.cue-list li {
  font-size: 14px; color: var(--ink-2); padding: 7px 0 7px 16px;
  border-left: 2px solid var(--line);
}
.cue-list li.on { border-color: var(--sage); color: var(--ink); }

.practice-controls {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  padding-top: 18px; transition: opacity .6s ease;
}
.eyes-exit {
  position: fixed; inset: auto 0 26px 0; text-align: center; opacity: 0;
  transition: opacity .6s ease; font-size: 12px; letter-spacing: .08em;
}

/* 웹캠 패널 — 호흡 오브와 같은 열에 놓여 자세 그림과 나란히 보인다 */
.cam-panel {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; padding: 16px; display: none; transition: opacity .6s;
}
.cam-panel.on { display: block; }
.cam-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.cam-head h4 { margin: 0; font-size: 14px; font-weight: 600; }
.cam-stage { position: relative; border-radius: 12px; overflow: hidden; background: #16160F; aspect-ratio: 4/3; width: 100%; }
.cam-stage video, .cam-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-stage video { opacity: .42; }
.align-score { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.align-bar { flex: 1; height: 6px; background: var(--sand-2); border-radius: 4px; overflow: hidden; }
.align-bar i { display: block; height: 100%; background: var(--sage); transition: width .4s; }
.align-score b { font-size: 18px; font-variant-numeric: tabular-nums; min-width: 46px; }
.cam-note { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* --------------------------------------------------------------------------
   가로 회전 — 자세 그림과 웹캠 교정을 한 화면에
   기기를 눕히면 헤더·푸터가 물러나고 화면 전체가 매트가 된다.
   왼쪽은 따라 할 동작, 오른쪽은 호흡 오브와 내 몸.
   -------------------------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 860px) {
  body.practice-mode { overflow-x: hidden; }
  body.practice-mode .app-header,
  body.practice-mode .foot { display: none; }
  body.practice-mode .app { max-width: none; padding: 0 16px; }

  body.practice-mode .practice {
    min-height: 100vh; min-height: 100dvh;
    padding-top: 8px;
  }
  body.practice-mode .practice-meta { font-size: 11.5px; }
  body.practice-mode .progress { margin-top: 6px; }

  body.practice-mode .stage {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px; padding: 6px 0; align-items: center;
  }
  body.practice-mode .side-col { gap: 8px; }

  /* 자세 그림 — 세로 공간에 맞춰 정사각을 유지한 채 줄어든다 */
  body.practice-mode .stage .pose-frame {
    width: min(100%, 60vh); max-width: none; border-radius: 18px;
  }
  body.practice-mode .pose-name { margin: 10px 0 1px; font-size: 19px; }
  body.practice-mode .pose-sa { font-size: 12px; }

  /* 호흡 오브 — 옆으로 눕히고 작게. 캠을 켜면 더 작아진다 */
  body.practice-mode .breath-wrap { flex-direction: row; align-items: center; justify-content: center; gap: 12px; }
  body.practice-mode .breath-orb { width: 96px; height: 96px; }
  body.practice-mode .breath-orb b { font-size: 12px; letter-spacing: .08em; }
  body.practice-mode .breath-count { font-size: 12px; }
  body.practice-mode .side-col .cue-list { display: none; }

  body.practice-mode.cam-on .breath-orb { width: 62px; height: 62px; }
  body.practice-mode.cam-on .breath-orb b { font-size: 10px; letter-spacing: .04em; }

  /* 웹캠 패널 — 가로에서는 화면·점수만 남기고 설명을 접는다 */
  body.practice-mode .cam-panel { padding: 8px; border-radius: 14px; }
  body.practice-mode .cam-head { margin-bottom: 7px; }
  body.practice-mode .cam-head h4 { font-size: 12px; }
  body.practice-mode .cam-head h4 span { display: none; }
  body.practice-mode .cam-note {
    font-size: 10.5px; margin-top: 5px; line-height: 1.35;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  body.practice-mode .cam-stage { max-height: 28vh; }
  body.practice-mode .align-score { margin-top: 6px; gap: 10px; }
  body.practice-mode .align-score b { font-size: 15px; min-width: 38px; }

  body.practice-mode .practice-controls { gap: 7px; padding-top: 8px; }
  body.practice-mode .practice-controls .btn { padding: 7px 13px; font-size: 12.5px; }
  body.practice-mode .practice-controls .btn.primary { padding: 8px 20px; font-size: 13px; }

  /* 캠이 꺼져 있으면 오브가 가운데를 넉넉히 쓴다 */
  body.practice-mode:not(.cam-on) .stage { grid-template-columns: minmax(0, 1fr) minmax(0, 300px); }
  body.practice-mode:not(.cam-on) .breath-orb { width: 132px; height: 132px; }
}

/* 태블릿처럼 가로로도 키가 넉넉한 화면 — 캠과 오브를 크게 */
@media (orientation: landscape) and (min-height: 620px) and (max-height: 860px) {
  body.practice-mode .cam-stage { max-height: 44vh; }
  body.practice-mode.cam-on .breath-orb { width: 84px; height: 84px; }
  body.practice-mode.cam-on .breath-orb b { font-size: 12px; }
  body.practice-mode .cam-panel { padding: 14px; }
  body.practice-mode .cam-head h4 { font-size: 13px; }
  body.practice-mode .cam-note { font-size: 12px; }
  body.practice-mode .pose-name { font-size: 23px; }
}

/* ---------- 완료 ---------- */
.done-hero { text-align: center; padding: 60px 0 30px; }
.done-hero h2 { font-size: 34px; font-weight: 660; letter-spacing: -.03em; margin: 0 0 10px; }
.done-hero p { color: var(--ink-2); margin: 0 0 30px; }
.streak-row { display: flex; justify-content: center; gap: 40px; margin-bottom: 34px; }

/* ---------- 라이브러리 ---------- */
.lib-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 16px; }
.lib-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; cursor: pointer; transition: all .18s ease;
}
.lib-card:hover { border-color: var(--sage); transform: translateY(-2px); box-shadow: var(--shadow); }
.lib-card .thumb { background: var(--sand-2); border-radius: 10px; aspect-ratio: 1/1; overflow: hidden; }
.lib-card .thumb svg, .lib-card .thumb img { width: 100%; height: 100%; display: block; object-fit: contain; }
.lib-card h5 { margin: 10px 0 1px; font-size: 13.5px; font-weight: 580; }
.lib-card p { margin: 0; font-size: 11.5px; color: var(--muted); font-style: italic; }
.lib-card .lvl { display: inline-block; margin-top: 7px; font-size: 10.5px; letter-spacing: .05em;
  color: var(--sage); border: 1px solid var(--sage-2); border-radius: 99px; padding: 1px 8px; }

/* ---------- 모달 ---------- */
.modal { position: fixed; inset: 0; background: rgba(35,35,31,.42); display: none;
  place-items: center; padding: 24px; z-index: 40; backdrop-filter: blur(3px); }
.modal.on { display: grid; }
.modal-box { background: var(--sand); border-radius: 22px; max-width: 560px; width: 100%;
  padding: 28px; max-height: 86vh; overflow: auto; }
.modal-box .pose-frame { max-width: 260px; }

/* ---------- 도감 모달 · 한 자세만 따로 교정 ---------- */
.coach-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.modal-box .coach-info .pose-frame { max-width: 280px; margin: 0 auto 18px; }
.coach-name { margin: 0 0 2px; font-size: 24px; font-weight: 620; letter-spacing: -.02em; }
.coach-sa { color: var(--muted); font-size: 13px; font-style: italic; margin-bottom: 16px; }
.coach-info .cue-list { max-width: none; }
.coach-meta { margin-top: 16px; font-size: 12.5px; color: var(--ink-2); }
.coach-meta b { font-weight: 600; }

/* 카메라 열은 교정을 켜야 열린다 */
.coach-cam { display: none; }
.coach-cam .cam-head h4 span { font-weight: 400; color: var(--muted); }
.modal-box.coach { max-width: 1060px; }
.modal-box.coach .coach-cam { display: block; }

/* 내용이 길어져 모달이 스크롤돼도 버튼은 늘 손 닿는 곳에 */
.coach-actions {
  position: sticky; bottom: -28px; z-index: 2;
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 16px; padding: 12px 0 28px; background: var(--sand);
}

/* 넉넉한 화면 — 왼쪽 사진과 설명, 오른쪽 카메라 */
@media (min-width: 820px) {
  .modal-box.coach .coach-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 26px; align-items: start;
  }
}

/* 기기를 눕혔을 때 — 좁은 세로 공간에 두 열을 욱여넣는다 */
@media (orientation: landscape) and (max-height: 860px) {
  .modal { padding: 12px; }
  .modal-box { padding: 16px; max-height: 95vh; }
  .modal-box.coach .coach-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
  .modal-box.coach .coach-info .pose-frame { max-width: min(100%, 34vh); margin-bottom: 10px; }
  .modal-box.coach .coach-name { font-size: 18px; }
  .modal-box.coach .coach-sa { font-size: 11.5px; margin-bottom: 8px; }
  .modal-box.coach .cue-list li { font-size: 12px; padding: 4px 0 4px 12px; }
  .modal-box.coach .coach-meta { font-size: 11px; margin-top: 9px; }
  .modal-box.coach .cam-head h4 { font-size: 12.5px; }
  .modal-box.coach .cam-head h4 span { display: none; }
  .modal-box.coach .cam-stage { max-height: 44vh; }
  .modal-box.coach .cam-note { font-size: 11px; }
  .coach-actions { bottom: -16px; margin-top: 10px; padding: 10px 0 16px; }
}

.foot { margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted); }

/* ---------- 설치 배너 ---------- */
.install-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(0);
  z-index: 60; display: flex; align-items: center; gap: 14px;
  width: calc(100% - 32px); max-width: 560px;
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; box-shadow: 0 4px 12px rgba(35,35,31,.07), 0 18px 44px rgba(35,35,31,.13);
  animation: slideUp .45s cubic-bezier(.2,.8,.3,1);
}
.install-bar[hidden] { display: none; }
@keyframes slideUp { from { opacity: 0; transform: translateX(-50%) translateY(24px); } }
.install-ico { width: 46px; height: 46px; border-radius: 12px; flex: none; }
.install-txt { flex: 1; min-width: 0; }
.install-txt b { display: block; font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; }
.install-txt span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.install-act { display: flex; align-items: center; gap: 4px; flex: none; }
/* 수련 중이나 자세를 들여다보는 중에는 아무것도 끼어들지 않는다 */
body.eyes-closed .install-bar,
body.practice-mode .install-bar,
body.modal-open .install-bar { display: none; }

@media (max-width: 560px) {
  .install-bar { flex-wrap: wrap; gap: 10px; padding: 13px 14px; bottom: 12px; }
  .install-txt { flex: 1 1 calc(100% - 60px); }
  .install-act { flex: 1 1 100%; justify-content: flex-end; }
}
