:root {
  --bg: #060b12;
  --glass: rgba(12, 20, 32, 0.74);
  --glass2: rgba(18, 30, 46, 0.8);
  --line: rgba(150, 190, 230, 0.16);
  --txt: #e6eef6;
  --dim: #8fa3b8;
  --acc: #6fd3ff;
  --yel: #ffd479;
  --grn: #7dffb0;
  --dock: 300px;
  --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); }
.warn { color: #ffb4a0; }
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.06em; color: var(--dim); font-weight: 600; margin: 0 0 8px; }
.ph span { font-weight: 400; opacity: 0.7; margin-left: 4px; }

#brand { position: fixed; left: 22px; top: 16px; z-index: 6; pointer-events: none; text-shadow: 0 2px 18px rgba(0,0,0,0.6); }
#brand::before { content: ""; position: absolute; left: -40px; top: -30px; right: -60px; bottom: -24px; z-index: -1; background: radial-gradient(closest-side, rgba(4,8,14,0.72), rgba(4,8,14,0)); }
#brand .kicker { font-size: 11.5px; color: var(--yel); letter-spacing: 0.06em; font-weight: 600; }
#brand h1 { margin: 2px 0 0; font-size: 32px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;
  background: linear-gradient(180deg, #ffffff 10%, #ffe2a0 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
#brand .sub { font-size: 13px; color: var(--dim); margin-top: 3px; font-weight: 500; }
#brand .sub span { opacity: 0.7; }

#scenes { left: 16px; top: 100px; width: 300px; bottom: calc(var(--dock) + 30px); padding: 12px; 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: 7px 9px; cursor: pointer; transition: all .18s; }
.scn:hover { background: rgba(255,212,121,0.07); border-color: rgba(255,212,121,0.35); }
.scn.on { background: linear-gradient(135deg, rgba(255,212,121,0.18), rgba(255,212,121,0.04)); border-color: rgba(255,212,121,0.55); }
.scn b { display: block; font-size: 13px; font-weight: 700; line-height: 1.3; }
.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.6; font-size: 12.5px; }
.card h2 { margin: 0; font-size: 17px; font-weight: 800; }
.card .en { font-size: 11.5px; color: var(--yel); margin-bottom: 6px; font-weight: 600; }
.card p { margin: 6px 0; color: #cfdbe7; word-break: keep-all; }
.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); word-break: keep-all; }
.card .look::before { content: "▸ 관찰 요소  "; font-weight: 700; }

#ctrl { right: 16px; top: 56px; width: 280px; bottom: calc(var(--dock) + 30px); padding: 10px 14px; overflow: auto; scrollbar-width: thin; }
.grp { padding: 8px 0; border-top: 1px solid var(--line); }
.grp:first-child { border-top: 0; padding-top: 2px; }
.lbl { font-size: 12px; color: var(--dim); margin-bottom: 6px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.lbl.sub { margin: 8px 0 4px; }
.lbl em, .tog em { font-style: normal; font-weight: 400; font-size: 11px; color: #6f8499; }
.lbl output { margin-left: auto; font-size: 11px; color: #b8c9da; }
.mini { margin-left: auto; font-size: 11px; background: rgba(255,212,121,0.1); border: 1px solid rgba(255,212,121,0.4); color: #ffe6ad; border-radius: 99px; padding: 2px 8px; cursor: pointer; }
.seg { display: flex; background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg.wrap { flex-wrap: wrap; } .seg.wrap button { flex: 1 0 30%; }
.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); white-space: nowrap; }
.seg button i { display: block; font-style: normal; font-family: var(--mono); font-size: 10px; font-weight: 400; opacity: 0.8; }
.seg.sm button { padding: 4px 3px; font-size: 11.5px; }
.seg button.on { background: rgba(255,212,121,0.17); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,212,121,0.45); }
.row { display: flex; align-items: center; gap: 8px; }
.row .rl { font-size: 12px; color: #b8c9da; width: 38px; flex: none; }
.row output { min-width: 50px; text-align: right; color: #ffe6ad; }
output.inl { margin-left: 4px; color: #ffe6ad; font-size: 11.5px; }
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: 9px 0; min-width: 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: #fff4d6; border: 2px solid var(--yel); cursor: pointer; box-shadow: 0 0 0 4px rgba(255,212,121,0.12); }
input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #fff4d6; border: 2px solid var(--yel); cursor: pointer; }
.tog { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 12.5px; user-select: none; margin-top: 6px; }
.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(255,212,121,0.6); }
.tog input:checked + span::after { transform: translateX(12px); background: #fff; }
.hint { font-size: 11px; color: var(--dim); margin-top: 2px; line-height: 1.45; }

#legend { left: 50%; transform: translateX(-50%); top: 14px; padding: 7px 12px 6px; display: flex; gap: 16px; align-items: flex-start; max-width: calc(100vw - 680px); flex-wrap: wrap; justify-content: center; }
.lg { min-width: 180px; }
.lg .t { font-size: 11.5px; color: var(--dim); margin-bottom: 3px; display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.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.rays { min-width: 0; }
.lg.rays .sw { display: flex; gap: 10px; font-size: 11.5px; white-space: nowrap; }
.lg.rays i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: 3px; }

#dock { left: 16px; right: 16px; bottom: 16px; height: var(--dock); display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; padding: 8px 12px 8px; }
.secwrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sechead { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; min-height: 26px; }
#secTitle { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#secTitle .dim { font-weight: 500; font-size: 12px; }
.sechead .seg { flex: none; width: 140px; }
.sechead .segZoom { width: 170px; }
.sechead .mini { margin-left: 0; }
.secbox { position: relative; flex: 1; min-height: 0; }
#sec { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; border-radius: 8px; }
#secBusy { position: absolute; right: 16px; top: 8px; font-size: 11px; color: var(--yel); background: rgba(6,12,20,0.8); padding: 2px 8px; border-radius: 99px; }
.secfoot { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; color: #b8c9da; min-height: 17px; margin-top: 3px; white-space: nowrap; overflow: hidden; }
.secfoot b { color: #fff; font-weight: 600; font-family: var(--mono); font-size: 11px; }
#secRead { text-align: right; overflow: hidden; text-overflow: ellipsis; }
.arrwrap { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); padding-left: 12px; }
.tabs { display: flex; gap: 3px; margin-bottom: 3px; }
.tabs button { background: none; border: 0; padding: 4px 8px; font-size: 12px; color: var(--dim); cursor: pointer; border-radius: 7px; font-weight: 600; }
.tabs button.on { color: #fff; background: rgba(255,212,121,0.15); }
#arr { flex: 1; min-height: 0; width: 100%; display: block; }
.note { font-size: 11px; color: #b8c9da; margin-top: 3px; line-height: 1.45; }
.note b { color: #fff; font-family: var(--mono); font-weight: 600; font-size: 11px; }
.play { display: flex; gap: 8px; align-items: center; margin-top: 5px; }
.play .seg { flex: 1; }
.pbtn { display: flex; gap: 4px; }
.pbtn button { border: 1px solid rgba(125,255,176,0.45); background: rgba(125,255,176,0.1); color: #dfffea; border-radius: 8px; padding: 5px 8px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.pbtn button:disabled { opacity: 0.35; cursor: default; }
#playSrc { border-color: rgba(255,212,121,0.45); background: rgba(255,212,121,0.1); color: #fff0cc; }

#tip { position: fixed; z-index: 20; pointer-events: none; background: rgba(6, 12, 20, 0.92); border: 1px solid rgba(255,212,121,0.35); border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.55; min-width: 190px; max-width: 280px; box-shadow: 0 8px 30px rgba(0,0,0,0.45); }
#tip .v { font-family: var(--mono); color: #fff; }
#tip .v2 { color: #fff; }
#tip .k { color: var(--dim); display: inline-block; min-width: 42px; margin-right: 6px; }
#tip .sep { border-top: 1px solid var(--line); margin: 4px 0; }
#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; left: 0; top: 0; 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; opacity: 0; }
.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(200,230,255,0.75); }
.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); }
.lab.mark { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: rgba(6,12,20,0.7); text-shadow: none; }
.lab.srcLab { color: var(--yel); border: 1px solid rgba(255,212,121,0.5); }
.lab.endLab { color: #bfefff; border: 1px solid rgba(158,231,255,0.4); }
.lab.rcvLab { color: var(--grn); border: 1px solid rgba(125,255,176,0.45); }

.pill { position: fixed; z-index: 6; right: 16px; top: 14px; 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(255,212,121,0.5); }
#credit { position: fixed; right: 18px; bottom: 1px; font-size: 10px; color: rgba(160,180,200,0.55); z-index: 4; pointer-events: none; }

dialog#about { max-width: 700px; width: calc(100vw - 32px); max-height: calc(100vh - 40px); 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(--yel); }
dialog ul { padding-left: 18px; margin: 4px 0; }
dialog li { margin: 3px 0; color: #cfdbe7; word-break: keep-all; }
dialog p { word-break: keep-all; }
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(255,212,121,0.15); border-top-color: var(--yel); 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(--yel); 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; }

@media (max-height: 820px) and (min-width: 761px) { :root { --dock: 270px; } #brand h1 { font-size: 28px; } #scenes { top: 90px; } }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  html, body { font-size: 13px; }
  #brand { left: 12px; top: 8px; }
  #brand h1 { font-size: 22px; }
  #brand .kicker { font-size: 10px; }
  #brand .sub { font-size: 10.5px; }
  .pill { right: 10px; top: 10px; padding: 5px 10px; font-size: 11.5px; }
  #credit { display: none; }
  #legend { left: 8px; right: 8px; transform: none; max-width: none; top: auto; bottom: calc(52vh + 58px + env(safe-area-inset-bottom)); gap: 8px; padding: 4px 8px; }
  #legend .lg { min-width: 0; flex: 1 1 100%; } #legend .lg:not(:last-child) { display: none; }
  #scenes, #ctrl, #dock { left: 6px; right: 6px; width: auto; top: auto; bottom: calc(50px + env(safe-area-inset-bottom)); height: 52vh; max-height: none; display: none; border-radius: 14px; }
  #scenes.show, #ctrl.show { display: block; }
  #dock.show { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; }
  #sceneList { grid-template-columns: repeat(2, 1fr); }
  .scn.wide { grid-column: span 2; } .scn i { display: none; }
  .secwrap { flex: 1.25; }
  .sechead { font-size: 12px; min-height: 22px; gap: 6px; } #secTitle .dim { display: none; }
  .sechead .seg { width: 104px; } .sechead .segZoom { width: 132px; } #bReplay { display: none; }
  .secfoot { flex-direction: column; gap: 0; white-space: normal; font-size: 10.5px; }
  #secRead { text-align: left; }
  .arrwrap { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 3px; flex: 1; }
  .tabs button { padding: 3px 6px; font-size: 11.5px; }
  .play .seg button { font-size: 11px; }
  .note { font-size: 10.5px; }
  #mtabs { display: flex; position: fixed; left: 6px; right: 6px; bottom: calc(4px + 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(255,212,121,0.16); color: #fff; }
  #tip { max-width: 240px; }
}
.rk { display: inline-block; width: 12px; height: 3px; border-radius: 2px; background: var(--c); margin: 0 4px 0 2px; vertical-align: 3px; }
