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

html, body {
  height: 100%;
  background: #0b0f14;
  color: #e8edf2;
  font-family: -apple-system, "Apple SD Gothic Neo", "Pretendard", sans-serif;
  overflow: hidden;
}

/* 상단바(기본 기조: 뒤로 · 상태칩 · 홈) — 최소화 */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-top, 0px));
  background: linear-gradient(to bottom, rgba(11,15,20,.72), rgba(11,15,20,0));
}
.navbtn {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: rgba(20,28,36,.5); border: 1px solid rgba(255,255,255,.16); color: #e8edf2;
  text-decoration: none; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: transform .12s ease;
}
.navbtn:active { transform: scale(.9); }
.navbtn.home { color: #b9a8ff; }
.navbtn svg { width: 24px; height: 24px; }
#status {
  flex: 1; min-width: 0; text-align: center;
  font-size: 13px; font-weight: 600; color: #dbe4ec;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}

/* 경혈명 가리기 스위치 (우상단, 홈버튼 아래) — 셀프 퀴즈 모드
   글자는 배경 없이, 스위치(트랙)에만 반투명 흰 배경 */
#hide-names {
  position: fixed; top: calc(64px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 4px; background: none; border: none; cursor: pointer;
  transition: transform .12s ease;
}
#hide-names:active { transform: scale(.96); }
#hide-names .hn-label {
  font-size: 12.5px; font-weight: 400; color: #f0eef8; letter-spacing: -.3px;
  text-shadow: 0 1px 4px rgba(0,0,0,.55);
}
#hide-names .hn-track {
  flex: none; width: 40px; height: 23px; border-radius: 999px;
  background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.5);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
  position: relative; transition: background .18s ease;
}
#hide-names .hn-knob {
  position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: #6a4df0; box-shadow: 0 1px 4px rgba(0,0,0,.3); transition: transform .18s ease, background .18s ease;
}
#hide-names.on .hn-track { background: #6a4df0; border-color: #6a4df0; }
#hide-names.on .hn-knob { background: #fff; transform: translateX(17px); }
#hide-names.on .hn-label { color: #cbbdff; }

/* 카메라 전환 FAB (우하단) */
#cam-flip {
  position: fixed; right: 14px; bottom: calc(112px + env(safe-area-inset-bottom, 0px)); z-index: 21;
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20,28,36,.55); border: 1px solid rgba(255,255,255,.22); color: #e8edf2;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  transition: transform .12s ease;
}
#cam-flip:active { transform: scale(.9); }
#cam-flip:disabled { opacity: .5; }
#cam-flip svg { width: 24px; height: 24px; }

#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000;
}

/* 카메라 뜨기 전 블랙스크린 구간을 채우는 로딩 오버레이 */
#load-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: #05070a; transition: opacity .35s ease;
}
#load-overlay.hidden { opacity: 0; pointer-events: none; }
.load-spin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(110,231,183,.18); border-top-color: #6ee7b7;
  animation: chip-spin .8s linear infinite;
}
#load-text {
  font-size: 13px; color: #b9c6d2; text-align: center; letter-spacing: -.2px;
}
.load-bar {
  width: min(220px, 60vw); height: 5px; border-radius: 999px;
  background: rgba(255,255,255,.1); overflow: hidden;
}
#load-bar-fill {
  height: 100%; width: 6%; border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #6ee7b7);
  transition: width .4s ease;
}
@media (prefers-reduced-motion: reduce) {
  .load-spin { animation-duration: 1.6s; }
}
#cam { display: none; }
#view {
  max-width: 100vw; max-height: 100vh;
  width: auto; height: auto;
}

#controls {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  padding: 10px 14px 14px;
  background: linear-gradient(to top, rgba(11,15,20,.94), rgba(11,15,20,0));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #2b3a47; background: rgba(20,28,36,.85); color: #b9c6d2;
  padding: 8px 16px; border-radius: 999px; font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.chip.active { background: #10b981; border-color: #10b981; color: #04110c; font-weight: 700; }
/* 골격/근육/동맥/신경 탭: 3D 자산(three.js + 뼈 STL)을 백그라운드로 받는 동안 표시하는 스피너.
   경혈은 항상 즉시 사용 가능하므로 대상 아님. */
.chip-spinner {
  display: none; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid rgba(185,198,210,.35); border-top-color: #6ee7b7;
  animation: chip-spin .7s linear infinite;
}
.chip.loading .chip-spinner { display: inline-block; }
.chip.active .chip-spinner { border-color: rgba(4,17,12,.3); border-top-color: #04110c; }
@keyframes chip-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .chip-spinner { animation-duration: 1.6s; }
}
.credit { font-size: 10px; color: #7b8794; text-align: center; max-width: 520px; line-height: 1.55; }

#info-card {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: 96px;
  width: min(440px, calc(100vw - 24px));
  background: rgba(15, 22, 30, .96); border: 1px solid #2b3a47;
  border-radius: 14px; padding: 16px 18px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
#info-card h2 { font-size: 18px; }
#info-card .meridian { font-size: 12px; color: #6ee7b7; margin: 4px 0 10px; }
#info-card dl { font-size: 13px; line-height: 1.55; }
#info-card dt { color: #8b98a5; font-size: 11px; margin-top: 8px; }
#info-card dd { color: #dde5ec; }
#info-card dd.csv { color: #b9c6d2; font-size: 12px; }
#info-card dt.csv { color: #6ea8d8; }
#info-card .safety {
  margin-top: 10px; padding: 8px 10px; border-radius: 8px;
  background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .4);
  color: #fca5a5; font-size: 12px; line-height: 1.5;
}
#info-close {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; color: #8b98a5; font-size: 20px; cursor: pointer;
}

#error-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: #7f1d1d; color: #fecaca; font-size: 13px;
  padding: 10px 16px; white-space: pre-wrap;
}

#bone-toast {
  position: fixed; z-index: 40; left: 50%; bottom: 120px; transform: translateX(-50%);
  background: rgba(20, 28, 36, .92); color: #eef3f7;
  border: 1px solid #4a5a68; border-radius: 999px;
  padding: 10px 20px; font-size: 16px; font-weight: 700; letter-spacing: -.2px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5); pointer-events: none; white-space: nowrap;
}

.hidden { display: none !important; }

#anatomy-status { color: #9fb6ba; font-size: 11px; }
#region-point-status { color: #ead5ac; font-size: 12px; line-height: 1.5; padding: 0 12px; }
#body-status, #head-status { color: #ead5ac; font-size: 11px; line-height: 1.5; padding: 0 12px; }
.body-preview-controls { margin: 5px 0; font-size: 12px; }
.body-preview-controls button { border: 1px solid #557c7e; border-radius: 14px; padding: 6px 12px; color: #d5eeeb; background: #183235; cursor: pointer; }
.body-preview-controls button[aria-pressed="true"] { background: #326c65; }
.body-preview-controls a { color: #a5c9c7; margin-left: 8px; }
.anatomy-settings { width:min(1280px,100%); text-align:center; color:#b9cec9; font-size:12px; }
.anatomy-settings>summary { cursor:pointer; padding:5px 12px; }
.anatomy-settings[open] { max-height:40vh; overflow-y:auto; padding:10px; background:rgba(11,20,25,.97); border:1px solid #41545e; border-radius:12px; }
.anatomy-settings[open]>summary { position:sticky; top:-10px; background:#0b1419; }
.anatomy-settings a { color:#a5c9c7; }
.anatomy-adjustments { display:flex; flex-wrap:wrap; justify-content:center; gap:6px 18px; color:#c4d4d9; }
.anatomy-adjustments label { display:flex; align-items:center; gap:6px; }
.anatomy-adjustments input[type=range] { width:100px; accent-color:#57b8a6; }
.anatomy-adjustments input[type=checkbox] { width:auto; accent-color:#57b8a6; }
.anatomy-adjustments output { min-width:34px; font-variant-numeric:tabular-nums; }
#capture-scope { color:#d5eeeb; background:#183235; border:1px solid #557c7e; border-radius:6px; padding:5px; max-width:280px; }
.camera-controls { max-width:900px; width:100%; text-align:center; color:#c4d4d9; font-size:12px; }
.camera-controls[hidden] { display:none; }
.camera-controls summary { cursor:pointer; padding:4px; }
.camera-controls[open] { background:rgba(11,20,27,.96); border:1px solid #557c7e; border-radius:10px; padding:8px; max-height:30vh; overflow:auto; }
.camera-controls select { color:#d5eeeb; background:#183235; border:1px solid #557c7e; border-radius:6px; padding:5px; max-width:240px; }
#tracking-review-panel[hidden] { display: none; }
#tracking-review-panel { position: fixed; z-index: 25; top: 70px; right: 16px; width: min(370px, calc(100vw - 32px)); background: #121c29ed; border: 1px solid #385265; border-radius: 14px; padding: 14px; color: #d7e5ef; box-shadow: 0 12px 40px #0005; }
.review-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.review-title span { font-size: 10px; color: #e7c68e; border: 1px solid #7b623a; padding: 3px 6px; border-radius: 5px; }
.review-title a { color: #7edbe1; font-size: 11px; margin-left: auto; }
.review-controls { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; font-size: 12px; }
.review-controls label { display: flex; align-items: center; gap: 6px; }
.review-controls select,.review-controls button { background: #203448; color: #e0eaf2; border: 1px solid #486177; border-radius: 5px; padding: 5px; font: inherit; }
.review-controls input[type=range] { width: 125px; accent-color: #68d5bf; }
#tracking-review-panel p { font-size: 10px; margin-top: 10px; color: #9aadb9; }
.tracking-review #stage { padding-right: 370px; }
.tracking-review #view { max-width: calc(100vw - 370px); }
.tracking-review #hide-names { top: 76px; }
@media(max-width: 850px) { .tracking-review #stage { padding: 235px 0 120px; } .tracking-review #view { max-width: 100vw; max-height: calc(100vh - 340px); } #tracking-review-panel { top: 68px; right: 12px; left: 12px; width: auto; } .tracking-review #hide-names { display: none; } }
#cam-flip[hidden] { display: none; }
#meridian-panel { position:fixed; z-index:35; right:12px; top:115px; width:146px; max-height:calc(100dvh - 340px); overflow-y:auto; padding:12px; border:1px solid #41545e; border-radius:14px; color:#e1eee9; background:rgba(13,25,31,.9); backdrop-filter:blur(8px); }
#meridian-panel[hidden] { display:none; }
#meridian-panel h2,#meridian-panel h3 { margin:0 0 8px; font-size:13px; }
#meridian-panel h3 { margin-top:12px; }
.meridian-grid { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
#meridian-panel button { min-height:32px; border:1px solid #52616b; border-radius:7px; color:#b2bfc6; background:#1c2a33; font:inherit; font-size:12px; cursor:pointer; }
#meridian-panel button[aria-pressed=true] { color:#04231b; background:#69d6b3; border-color:#69d6b3; font-weight:700; }
.meridian-actions { display:flex; gap:4px; margin-bottom:8px; }
.meridian-actions button { flex:1; font-size:10px!important; }
#meridian-panel small { display:block; margin-top:9px; color:#abbcc5; font-size:10px; line-height:1.5; }
.tracking-review #meridian-panel { right:390px; }
@media(max-width:850px){ #meridian-panel { right:6px; width:112px; padding:8px; top:90px; max-height:calc(100dvh - 325px); } .tracking-review #meridian-panel { right:6px; top:285px; } #meridian-panel button { min-height:30px; } }
