:root {
  --bg: #060b12;
  --glass: rgba(12, 20, 32, 0.72);
  --glass2: rgba(18, 30, 46, 0.78);
  --line: rgba(150, 190, 230, 0.16);
  --txt: #e6eef6;
  --dim: #8fa3b8;
  --acc: #6fd3ff;
  --yel: #ffd479;
  --cold: #6cc8ff;
  --warm: #ff9a4a;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--txt); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; }
body { background: radial-gradient(120% 90% at 50% 20%, #0d1c2c 0%, #060b12 60%, #04070b 100%); }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
.mono, output { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--dim); }
button { font-family: inherit; color: inherit; }

.panel { position: fixed; background: var(--glass); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,0.35); z-index: 5; }
.panel.slim { border-radius: 12px; }
.ph { font-size: 12px; letter-spacing: 0.08em; color: var(--dim); font-weight: 600; margin: 0 0 8px; text-transform: none; }
.ph span { font-weight: 400; opacity: 0.7; margin-left: 4px; }

#brand { position: fixed; left: 22px; top: 18px; z-index: 6; pointer-events: none; text-shadow: 0 2px 18px rgba(0,0,0,0.6); }
#brand .kicker { font-size: 11.5px; color: var(--acc); letter-spacing: 0.06em; font-weight: 600; }
#brand h1 { margin: 2px 0 0; font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;
  background: linear-gradient(180deg, #ffffff 10%, #9fd8ff 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
#brand .sub { font-size: 13px; color: var(--dim); margin-top: 3px; font-weight: 500; letter-spacing: 0.01em; }
#brand .sub span { opacity: 0.7; }

/* scenes */
#scenes { left: 16px; top: 108px; width: 300px; padding: 12px; max-height: calc(100vh - 124px); overflow: auto; scrollbar-width: thin; }
#sceneList { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.scn { text-align: left; background: rgba(255,255,255,0.035); border: 1px solid var(--line); border-radius: 10px; padding: 8px 9px; cursor: pointer; transition: all .18s; }
.scn:hover { background: rgba(111,211,255,0.08); border-color: rgba(111,211,255,0.35); }
.scn.on { background: linear-gradient(135deg, rgba(111,211,255,0.18), rgba(111,211,255,0.05)); border-color: rgba(111,211,255,0.55); }
.scn b { display: block; font-size: 13.5px; font-weight: 700; }
.scn i { display: block; font-style: normal; font-size: 10.5px; color: var(--dim); margin-top: 1px; }
.scn.wide { grid-column: span 2; }
.card { margin-top: 10px; padding: 11px 12px 10px; border-radius: 12px; background: var(--glass2); border: 1px solid var(--line); line-height: 1.55; font-size: 12.5px; }
.card h2 { margin: 0; font-size: 17px; font-weight: 800; }
.card .en { font-size: 11.5px; color: var(--acc); margin-bottom: 6px; font-weight: 600; letter-spacing: 0.02em; }
.card p { margin: 6px 0; color: #cfdbe7; }
.card .facts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.card .facts span { font-size: 11px; padding: 3px 7px; border-radius: 99px; background: rgba(111,211,255,0.09); border: 1px solid rgba(111,211,255,0.22); color: #bfe8ff; }
.card .look { margin-top: 8px; font-size: 12px; color: var(--yel); }
.card .look::before { content: "▸ 관찰 요소  "; font-weight: 700; }

/* layers */
#right { position: fixed; right: 16px; top: 16px; bottom: 16px; width: 272px; display: flex; flex-direction: column; gap: 10px; z-index: 5; pointer-events: none; }
#right > .panel { position: relative; pointer-events: auto; }
#layers { padding: 11px 14px; flex: 0 1 auto; min-height: 0; overflow: auto; scrollbar-width: thin; }
.grp { padding: 7px 0; border-top: 1px solid var(--line); }
.grp:first-of-type { border-top: 0; padding-top: 0; }
.lbl { font-size: 12px; color: var(--dim); margin-bottom: 6px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.lbl em, .tog em { font-style: normal; font-weight: 400; font-size: 11px; color: #6f8499; margin-left: 4px; }
.seg { display: flex; background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px 4px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--dim); }
.seg.sm button { padding: 4px 4px; font-size: 12px; }
.seg button.on { background: rgba(111,211,255,0.18); color: #fff; box-shadow: inset 0 0 0 1px rgba(111,211,255,0.4); }
.row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.row output { min-width: 58px; text-align: right; color: #d7ecff; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 4px; background: rgba(255,255,255,0.14); border-radius: 4px; outline: none; margin: 8px 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: #dff4ff; border: 2px solid var(--acc); cursor: pointer; box-shadow: 0 0 0 4px rgba(111,211,255,0.12); }
input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #dff4ff; border: 2px solid var(--acc); cursor: pointer; }
.tog { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; font-size: 13.5px; user-select: none; }
.tog.sm { font-weight: 500; font-size: 12.5px; margin-top: 4px; }
.tog input { display: none; }
.tog span { width: 28px; height: 16px; border-radius: 99px; background: rgba(255,255,255,0.14); position: relative; flex: none; transition: background .15s; }
.tog span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #c9d6e2; transition: transform .15s; }
.tog input:checked + span { background: rgba(111,211,255,0.55); }
.tog input:checked + span::after { transform: translateX(12px); background: #fff; }
.tog.cold input:checked + span { background: rgba(108,200,255,0.7); }
.tog.warm input:checked + span { background: rgba(255,154,74,0.75); }
.tog output { color: var(--txt); font-size: 12px; }
.hint { font-size: 11.5px; color: var(--yel); margin-top: 6px; opacity: 0.9; }
.grp.chk { display: flex; flex-wrap: wrap; gap: 2px 14px; }

/* analysis */
#analysis { flex: none; padding: 8px 10px 8px; }
.tabs { display: flex; gap: 4px; margin-bottom: 4px; }
.tabs button { background: none; border: 0; padding: 4px 8px; font-size: 12.5px; color: var(--dim); cursor: pointer; border-radius: 7px; font-weight: 600; }
.tabs button.on { color: #fff; background: rgba(111,211,255,0.14); }
#ts, #prof { width: 100%; height: 178px; display: block; }
.note { font-size: 10.5px; color: var(--dim); margin-top: 2px; line-height: 1.4; }
#tsDepthKey { display: inline-flex; gap: 4px; vertical-align: middle; margin-left: 2px; }
#tsDepthKey i { font-style: normal; font-family: var(--mono); font-size: 9.5px; padding: 0 3px; border-radius: 3px; color: #081018; }

/* legend */
#legend { left: calc(50% + 8px); transform: translateX(-50%); top: 16px; padding: 7px 12px 6px; display: flex; gap: 18px; align-items: center; }
.lg { min-width: 220px; }
.lg .t { font-size: 11.5px; color: var(--dim); margin-bottom: 3px; display: flex; justify-content: space-between; gap: 8px; }
.lg .t b { color: var(--txt); font-weight: 600; }
.lg .bar { height: 9px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1); }
.lg .ax { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10.5px; color: #b8c9da; margin-top: 2px; }
.lg.vol .sw { display: flex; gap: 10px; font-size: 12px; }
.lg.vol i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* time */
#timebar { left: calc(50% + 8px); transform: translateX(-50%); bottom: 16px; width: min(760px, calc(100vw - 660px)); min-width: 440px; padding: 8px 14px 8px 10px; display: flex; gap: 12px; align-items: center; }
#play { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(111,211,255,0.5); background: rgba(111,211,255,0.14); cursor: pointer; display: grid; place-items: center; flex: none; }
#play svg { width: 18px; height: 18px; fill: #e8f7ff; }
#play .i-pause { display: none; } #play.on .i-play { display: none; } #play.on .i-pause { display: block; }
.tl { flex: 1; min-width: 0; }
.tlhead { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; align-items: baseline; white-space: nowrap; }
.tlhead b { font-weight: 700; }
.tlhead span { font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
#track { position: relative; height: 30px; margin: 14px 14px 0 10px; cursor: pointer; touch-action: none; }
#ticks { position: absolute; inset: 0; }
#ticks::before { content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 3px; border-radius: 3px; background: rgba(255,255,255,0.12); }
.tk { position: absolute; top: 5px; transform: translateX(-50%); text-align: center; font-size: 10.5px; color: var(--dim); font-family: var(--mono); white-space: nowrap; }
.tk::before { content: ""; display: block; width: 1px; height: 10px; margin: 0 auto 2px; background: rgba(255,255,255,0.25); }
.tk.today { color: var(--yel); font-weight: 700; }
.tk.today::before { background: var(--yel); width: 2px; height: 11px; }
.tk.today::after { content: "오늘"; position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-family: var(--sans); font-size: 10px; background: var(--yel); color: #1a1405; padding: 0 5px; border-radius: 99px; font-weight: 800; }
#thumb { position: absolute; top: 3px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(111,211,255,0.35), 0 2px 8px rgba(0,0,0,0.5); pointer-events: none; }

#tip { position: fixed; z-index: 20; pointer-events: none; background: rgba(6, 12, 20, 0.9); border: 1px solid rgba(111,211,255,0.35); border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.55; min-width: 170px; box-shadow: 0 8px 30px rgba(0,0,0,0.45); }
#tip .v { font-family: var(--mono); color: #fff; }
#tip .k { color: var(--dim); display: inline-block; width: 34px; }
#tip .loc { color: var(--dim); font-family: var(--mono); font-size: 10.5px; margin-top: 3px; border-top: 1px solid var(--line); padding-top: 3px; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.lab { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; text-align: center; text-shadow: 0 1px 6px rgba(0,0,0,0.9), 0 0 2px rgba(0,0,0,0.9); transition: opacity .2s; }
.lab.sea { font-size: 15px; font-weight: 700; color: rgba(214,238,255,0.85); letter-spacing: 0.08em; }
.lab.sea i { display: block; font-style: normal; font-size: 9.5px; font-weight: 500; color: rgba(170,205,235,0.7); letter-spacing: 0.1em; }
.lab.land { font-size: 12px; color: rgba(225,220,200,0.6); font-weight: 600; letter-spacing: 0.3em; }
.lab.feat { font-size: 11px; color: rgba(255,212,121,0.8); }
.lab.feat::before { content: "◆ "; font-size: 7px; vertical-align: 2px; }
.lab.tick { font-family: var(--mono); font-size: 10px; color: rgba(200,220,240,0.8); transform: translate(6px, -50%); }
.lab.tick.l { transform: translate(calc(-100% - 6px), -50%); }
.lab.geo { font-family: var(--mono); font-size: 10px; color: rgba(180,200,220,0.6); }
.lab.axis { font-size: 10px; color: rgba(200,220,240,0.6); }

.pill { position: fixed; z-index: 6; right: 300px; top: 16px; background: var(--glass); border: 1px solid var(--line); border-radius: 99px; padding: 7px 12px; font-size: 12px; cursor: pointer; color: var(--txt); backdrop-filter: blur(10px); }
.pill:hover { border-color: rgba(111,211,255,0.5); }
#credit { position: fixed; right: 18px; bottom: 4px; font-size: 10px; color: rgba(160,180,200,0.55); z-index: 4; pointer-events: none; }

dialog#about { max-width: 640px; width: calc(100vw - 32px); background: #0b1622; color: var(--txt); border: 1px solid var(--line); border-radius: 16px; padding: 22px 26px; line-height: 1.65; font-size: 13.5px; }
dialog#about::backdrop { background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog h3 { margin: 16px 0 4px; font-size: 14px; color: var(--acc); }
dialog ul { padding-left: 18px; margin: 4px 0; }
dialog li { margin: 3px 0; color: #cfdbe7; }
dialog .x { position: absolute; right: 12px; top: 8px; background: none; border: 0; font-size: 26px; color: var(--dim); cursor: pointer; }

#loading { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, #0d1c2c, #04070b 70%); transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
.lb { text-align: center; color: var(--dim); font-size: 13px; }
.ring { width: 42px; height: 42px; margin: 0 auto 14px; border-radius: 50%; border: 3px solid rgba(111,211,255,0.15); border-top-color: var(--acc); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { width: 200px; height: 3px; background: rgba(255,255,255,0.1); border-radius: 3px; margin: 10px auto 0; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--acc); transition: width .3s; }
#err { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: #7a1d1d; color: #fff; padding: 6px 12px; font-size: 12px; font-family: var(--mono); }
#mtabs { display: none; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  html, body { font-size: 13px; }
  #right { display: contents; }
  #right > .panel { position: fixed; }
  #brand { left: 14px; top: 10px; }
  #brand h1 { font-size: 24px; }
  #brand .kicker { font-size: 10px; }
  #brand .sub { font-size: 11px; }
  .pill { right: 12px; top: 12px; padding: 6px 10px; }
  #credit { display: none; }
  #scenes, #layers, #analysis { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(118px + env(safe-area-inset-bottom)); max-height: 46vh; border-radius: 14px; display: none; }
  #scenes.show, #layers.show, #analysis.show { display: block; }
  #sceneList { grid-template-columns: repeat(3, 1fr); }
  .scn { padding: 6px 7px; } .scn b { font-size: 12.5px; } .scn i { display: none; } .scn.wide { grid-column: auto; }
  .card { font-size: 12.5px; }
  #legend { left: 8px; right: 8px; transform: none; top: auto; bottom: calc(118px + env(safe-area-inset-bottom)); justify-content: center; gap: 10px; padding: 5px 8px; flex-wrap: wrap; }
  .lg { min-width: 0; flex: 1; } .lg.vol { flex: none; }
  #legend.hidden { display: none; }
  #timebar { left: 8px; right: 8px; transform: none; width: auto; min-width: 0; bottom: calc(52px + env(safe-area-inset-bottom)); padding: 6px 10px 4px 8px; gap: 8px; }
  #play { width: 34px; height: 34px; }
  .tlhead { font-size: 12px; } .tlhead span { display: none; }
  .tk { font-size: 9px; } .tk span { display: none; }
  #mtabs { display: flex; position: fixed; left: 8px; right: 8px; bottom: calc(6px + env(safe-area-inset-bottom)); z-index: 7; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; backdrop-filter: blur(12px); }
  #mtabs button { flex: 1; border: 0; background: none; padding: 8px 0; font-size: 13px; font-weight: 700; color: var(--dim); border-radius: 9px; }
  #mtabs button.on { background: rgba(111,211,255,0.16); color: #fff; }
  #ts, #prof { height: 180px; }
}
