:root {
  --bg: #04060d;
  --panel: #0b1120;
  --line: #1c2a44;
  --text: #d7e3f4;
  --dim: #7f93b2;
  --accent: #38d0e8;
  --panel-w: 330px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; font-size: 14px; overflow: hidden; }

#panel { position: fixed; left: 0; top: 0; bottom: 0; width: var(--panel-w); background: var(--panel);
  border-right: 1px solid var(--line); overflow-y: auto; padding: 14px 14px 24px; z-index: 5; }
body.collapsed #panel { display: none; }
body.collapsed #stage { left: 0; }
body.collapsed #panelToggle { left: 0; }

#panel h1 { font-size: 18px; margin: 0 0 12px; color: var(--accent); }
#panel h2 { font-size: 12px; letter-spacing: .04em; color: var(--dim); margin: 16px 0 6px; text-transform: none; }
.row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.hint { color: var(--dim); font-size: 12px; margin-top: 4px; line-height: 1.4; }

input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=datetime-local] { flex: 1; min-width: 0; background: #0f1a30; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px; color-scheme: dark; }
button { background: #12203a; color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; cursor: pointer; font: inherit; }
button:hover { border-color: var(--accent); }
button.wide { width: 100%; }

#panelToggle { position: fixed; left: var(--panel-w); top: 12px; z-index: 6; width: 26px; height: 40px; padding: 0;
  border-radius: 0 8px 8px 0; background: var(--panel); }
#stage { position: fixed; left: var(--panel-w); right: 0; top: 0; bottom: 0; }
#stage canvas { display: block; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }   /* 이름표는 이 층 안에만: 정보창·목록보다 아래 */
.label { color: #cfe9ff; font-size: 12px; text-shadow: 0 0 4px #000, 0 0 2px #000; white-space: nowrap; margin-top: -18px; }
.label.sel { color: var(--accent); font-weight: bold; }

#simDate { position: absolute; left: 40px; top: 12px; font-size: 22px; font-weight: 600; letter-spacing: .02em;
  text-shadow: 0 0 6px #000; pointer-events: none; z-index: 3; }
body.collapsed #simDate { left: 40px; }
#status { position: absolute; left: 12px; bottom: 64px; font-size: 12px; color: var(--dim); text-shadow: 0 0 4px #000; z-index: 3;
  background: rgba(4,6,13,.7); padding: 2px 6px; border-radius: 4px; }
#status:empty { display: none; }
#credits { position: absolute; left: 12px; right: 12px; bottom: 8px; font-size: 11px; color: #8193b0; z-index: 3; }
#credits summary { cursor: pointer; width: max-content; padding: 2px 0; }
#credits details[open] summary { display: none; }   /* 펼친 뒤에는 글만 */

#loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 280px; text-align: center; z-index: 4;
  background: rgba(11,17,32,.9); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
#loading.done { display: none; }
#loadingBar { height: 6px; background: #14213a; border-radius: 3px; margin-top: 8px; overflow: hidden; }
#loadingFill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

#cards { display: flex; flex-direction: column; gap: 6px; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; background: #0d1527; }
.card:hover { border-color: #2c4a73; }
.card.sel { border-color: var(--accent); background: #0e1c33; }
.card .name { font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.card .stats { color: var(--dim); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.badge { font-size: 10.5px; font-weight: normal; padding: 1px 6px; border-radius: 9px; border: 1px solid var(--line); color: var(--dim); }
.badge.real { color: #6fe0a5; border-color: #2a6b4a; }
.badge.fictional { color: #ffc86b; border-color: #7a5a22; }
.badge.solid { color: #aab; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { flex: 1; text-align: center; cursor: pointer; }
.seg input { display: none; }
.seg span { display: block; padding: 6px 0; background: #0f1a30; }
.seg input:checked + span { background: var(--accent); color: #04121a; font-weight: 600; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.checks label { cursor: pointer; }
.checks input { accent-color: var(--accent); margin-right: 6px; }

.label.moon { font-size: 11px; color: #aebfd6; }
.label.moon.sel { color: var(--accent); }
details.host { margin-bottom: 6px; }
details.host > summary { cursor: pointer; color: var(--text); padding: 6px 2px; list-style: none; }
details.host > summary::before { content: '▸ '; color: var(--dim); }
details.host[open] > summary::before { content: '▾ '; }
details.host .cards-in { display: flex; flex-direction: column; gap: 6px; padding-left: 8px; }

.label.comet { font-size: 11px; color: #bfe3ff; }
.label.comet.sel { color: var(--accent); }
.label.comet.path { color: #ffb36b; font-size: 10.5px; opacity: .85; }   /* 성간천체 궤도선 이름표 */
.card .name input { accent-color: var(--accent); margin-right: 4px; }
.badge.comet { color: #8fd3ff; border-color: #2a5a7a; }
.badge.inter { color: #ffb86b; border-color: #8a5a22; }

.label.asteroid { font-size: 11px; color: #e0cfa8; }
.label.asteroid.sel { color: var(--accent); }

.label.voyager { font-size: 11.5px; color: #ffe29a; }
.label.voyager.sel { color: var(--accent); }

.maker { color: #9fb4d4; font-weight: 600; letter-spacing: .03em; }

/* ---- 폰·좁은 화면 (800px 이하) ---- */
#quickPause { display: none; }
@media (max-width: 800px) {
  :root { --panel-w: clamp(176px, 50vw, 240px); }   /* 폰에서는 메뉴 폭을 화면의 절반 정도로 */
  #panel { box-shadow: 4px 0 24px rgba(0,0,0,.6); padding: 8px 8px 80px; font-size: 12px; }
  #panel h1 { font-size: 14px; margin: 2px 0 6px; }
  #panel h2 { margin: 12px 0 4px; font-size: 11px; }
  #panel .row { flex-wrap: wrap; gap: 6px; }
  input[type=datetime-local] { font-size: 11px; padding: 6px 4px; min-width: 0; width: 100%; flex: 1 1 100%; }
  #panel button { padding: 8px 8px; font-size: 12px; }
  #panel button.wide { font-size: 11.5px; line-height: 1.3; }
  .hint { font-size: 11.5px; }
  .checks label { padding: 8px 0; display: block; }
  .card { padding: 7px 8px; }
  .card .stats { font-size: 11px; }
  .badge { font-size: 9.5px; padding: 1px 5px; }
  .seg span { padding: 10px 0; font-size: 12px; }
  #stage, body.collapsed #stage { left: 0; }           /* 패널은 화면 위에 겹쳐 나오고, 화면 크기는 그대로 */
  #panelToggle { top: 10px; width: 46px; height: 46px; font-size: 20px; border-radius: 0 12px 12px 0; }
  body.collapsed #panelToggle { border: 1px solid var(--accent); background: rgba(11,17,32,.92); }
  #simDate, body.collapsed #simDate { left: 62px; top: 14px; font-size: 15px; }
  #quickPause { display: block; position: fixed; right: 10px; top: 10px; z-index: 6; width: 46px; height: 46px; padding: 0; font-size: 18px;
    border-radius: 12px; background: rgba(11,17,32,.92); }
  body:not(.collapsed) #quickPause { display: none; }
  #status { bottom: 56px; font-size: 11.5px; max-width: 92%; }
  #credits { font-size: 10px; line-height: 1.4; }
  #credits summary { padding: 6px 0; }
  .label, .label.moon, .label.comet, .label.asteroid, .label.voyager { font-size: 11px; }
  #loading { width: 78%; }
}

/* 페이지 전환 버튼: 가려는 쪽의 색으로 칠해 한눈에 구분 */
.navbtn { display: block; text-align: center; font-weight: 700; font-size: 13px; text-decoration: none; padding: 9px 8px; border-radius: 8px; margin: 0 0 8px; color: #fff; }
.navbtn.to-sat { background: #c2410c; border: 1px solid #ff922b; }   /* 흰 글자 대비 5:1 이상 */
.navbtn.to-sat:hover { background: #d9480f; }
.navbtn.to-solar { background: #6741d9; border: 1px solid #9775fa; }
.navbtn.to-solar:hover { background: #7048e8; }
.navbtn.to-tel { background: #0b7285; border: 1px solid #3bc9db; }
.navbtn.to-tel:hover { background: #0c8599; }

/* 태양계: 선택한 천체 정보창 (위성 페이지 정보창과 같은 모양) */
#bodyCard { position: absolute; right: 12px; top: 12px; width: 300px; max-height: calc(100% - 110px); overflow-y: auto; z-index: 4;
  background: rgba(11,17,32,.96); border: 1px solid var(--line); border-radius: 8px; padding: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.6); }
#bodyCard[hidden] { display: none; }
#bodyCard h3 { margin: 0 0 6px; font-size: 15px; color: var(--accent); display: flex; gap: 8px; align-items: center; justify-content: space-between; padding-right: 4px; }
#bodyCard .stats { color: var(--text); font-size: 12.5px; line-height: 1.55; }
#bodyCard .note { margin-top: 8px; color: var(--dim); font-size: 11.5px; }
#bodyCard .closex { float: right; width: 36px; height: 36px; padding: 0; font-size: 18px; margin: -6px -6px 0 6px; }
#bodyCard .navbtn { margin-top: 8px; }
/* 첫 화면 안내 */
#firstTip { position: absolute; left: 50%; top: 56px; transform: translateX(-50%); z-index: 4; background: rgba(11,17,32,.92); border: 1px solid var(--accent);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; color: var(--text); pointer-events: none; transition: opacity .6s; max-width: 90%; text-align: center; }
#firstTip.gone { opacity: 0; }
@media (max-width: 800px) {
  #bodyCard { left: 8px; right: 8px; top: auto; bottom: 86px; width: auto; max-height: 45%; }
  #bodyCard .closex { width: 42px; height: 42px; }
  #firstTip { top: 66px; font-size: 12px; }
}
