:root {
  --bg: #03070d;
  --glass: rgba(9, 16, 27, 0.74);
  --glass2: rgba(16, 27, 42, 0.8);
  --line: rgba(150, 190, 230, 0.15);
  --txt: #e7eff7;
  --dim: #8ea2b7;
  --acc: #72e8ff;
  --yel: #ffd479;
  --amb: #ffb454;
  --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; }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: crosshair; }
.mono, output { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--dim); }
button { font-family: inherit; color: inherit; }
sub { font-size: 0.72em; }

.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: 700; 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.7); }
#brand .kicker { font-size: 11.5px; color: var(--acc); letter-spacing: 0.04em; font-weight: 600; }
#brand h1 { margin: 2px 0 0; font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.12;
  background: linear-gradient(100deg, #ffffff 0%, #bff3ff 45%, #ffc98a 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; }

/* cases */
#cases { left: 16px; top: 104px; width: 304px; padding: 12px; max-height: calc(100vh - 318px); overflow: auto; scrollbar-width: thin; }
#caseList { 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 .16s; }
.scn:hover { background: rgba(114,232,255,0.08); border-color: rgba(114,232,255,0.35); }
.scn.on { background: linear-gradient(135deg, rgba(114,232,255,0.18), rgba(114,232,255,0.04)); border-color: rgba(114,232,255,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: 2px; }
.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:empty { display: none; }
.card h2 { margin: 0; font-size: 16.5px; font-weight: 800; letter-spacing: -0.01em; }
.card .en { font-size: 11.5px; color: var(--acc); margin-bottom: 4px; 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(114,232,255,0.09); border: 1px solid rgba(114,232,255,0.22); color: #c4f3ff; }
.card .look { margin-top: 8px; font-size: 12px; color: var(--yel); word-break: keep-all; }
.card .look::before { content: "▸ 관찰 요소  "; font-weight: 700; }
.card .user b { color: #fff; }

/* right column */
#right { position: fixed; right: 16px; top: 16px; bottom: 96px; width: 318px; display: flex; flex-direction: column; gap: 10px; z-index: 5; pointer-events: none; }
#right > .panel { position: relative; pointer-events: auto; }
#release { padding: 11px 14px 12px; flex: 0 1 auto; min-height: 0; overflow: auto; scrollbar-width: thin; }
.hint { font-size: 12px; color: var(--yel); margin: -2px 0 6px; }
.grp { padding: 7px 0; border-top: 1px solid var(--line); }
.grp.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lbl { font-size: 12px; color: var(--dim); margin-bottom: 5px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.lbl em, .tog em { font-style: normal; font-weight: 400; font-size: 11px; color: #6f8499; margin-left: 2px; }
.lbl output { color: #d7ecff; margin-left: auto; }
.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); white-space: nowrap; }
.seg.sm button { padding: 4px 3px; font-size: 12px; }
.seg button.on { background: rgba(114,232,255,0.18); color: #fff; box-shadow: inset 0 0 0 1px rgba(114,232,255,0.4); }
input[type=date] { width: 100%; background: rgba(0,0,0,0.3); color: var(--txt); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-family: var(--mono); font-size: 12px; color-scheme: dark; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; background: rgba(255,255,255,0.14); border-radius: 4px; outline: none; margin: 6px 0 9px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: #dff8ff; border: 2px solid var(--acc); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #dff8ff; border: 2px solid var(--acc); 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: #cfd8e2; transition: transform .15s; }
.tog input:checked + span { background: rgba(114,232,255,0.55); }
.tog input:checked + span::after { transform: translateX(12px); background: #fff; }
.adv { border-top: 1px solid var(--line); padding-top: 6px; }
.adv summary { cursor: pointer; font-size: 12px; color: var(--dim); font-weight: 600; list-style: none; padding: 2px 0; }
.adv summary::before { content: "▸ "; } .adv[open] summary::before { content: "▾ "; }
.adv summary em { font-style: normal; font-weight: 400; color: #6f8499; font-size: 11px; margin-left: 4px; }
.adv .grp:first-of-type { border-top: 0; }
.btns { display: flex; gap: 6px; margin-top: 8px; }
.btns button { border-radius: 9px; padding: 7px 10px; font-size: 13px; font-weight: 700; cursor: pointer; }
.primary { flex: 1; border: 1px solid rgba(114,232,255,0.6); background: linear-gradient(135deg, rgba(114,232,255,0.3), rgba(114,232,255,0.1)); color: #fff; }
.primary:hover { background: rgba(114,232,255,0.35); }
.ghost { border: 1px solid var(--line); background: rgba(255,255,255,0.04); color: var(--dim); }

/* stats */
#stats { padding: 8px 12px 10px; flex: 1 1 auto; min-height: 150px; overflow: auto; scrollbar-width: thin; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 5px 4px; font-size: 12px; font-weight: 700; color: var(--dim); cursor: pointer; }
.tabs button.on { color: #fff; background: rgba(114,232,255,0.14); border-color: rgba(114,232,255,0.45); }
.sum { font-size: 12px; color: #cfdbe7; line-height: 1.55; margin-bottom: 4px; }
.sum b { font-family: var(--mono); font-weight: 400; color: #fff; }
canvas#chart { width: 100%; height: 118px; display: block; }
.key { display: flex; flex-wrap: wrap; gap: 3px 9px; font-size: 11px; color: var(--dim); margin: 4px 0 6px; }
.key i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
table.gt { width: 100%; border-collapse: collapse; font-size: 11.5px; }
table.gt th { text-align: left; color: var(--dim); font-weight: 600; padding: 3px 2px; border-bottom: 1px solid var(--line); font-size: 11px; }
table.gt td { padding: 3px 2px; border-bottom: 1px solid rgba(150,190,230,0.07); }
table.gt td.n { text-align: right; font-family: var(--mono); font-size: 11px; }
table.gt th.n { text-align: right; }
table.gt tr.z td { color: #5d6f82; }
.ctl { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
canvas#conn { width: 100%; display: block; }
canvas#skill { width: 100%; height: 110px; display: block; }
.note { font-size: 11.5px; color: var(--dim); line-height: 1.55; margin: 6px 0; word-break: keep-all; }
.note b { color: #dcecf9; font-weight: 600; }
.dlist { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.dlist button { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,0.03); border-radius: 8px; padding: 5px 8px; font-size: 12px; cursor: pointer; color: #cfdbe7; }
.dlist button:hover, .dlist button.on { border-color: rgba(255,212,121,0.6); background: rgba(255,212,121,0.08); }
.dlist button span { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-left: 4px; }

/* view bar */
#viewbar { left: 50%; transform: translateX(-50%); top: 14px; padding: 5px; display: flex; gap: 8px; align-items: center; }
#viewbar .seg { width: 130px; }
.chips { display: flex; gap: 4px; }
.chip { cursor: pointer; user-select: none; }
.chip input { display: none; }
.chip span { display: block; font-size: 12px; padding: 5px 9px; border-radius: 8px; border: 1px solid var(--line); color: var(--dim); font-weight: 600; }
.chip input:checked + span { color: #fff; border-color: rgba(114,232,255,0.45); background: rgba(114,232,255,0.12); }

/* legend */
#legend { left: 16px; bottom: 96px; padding: 8px 12px; width: 304px; font-size: 11.5px; }
#legend .t { color: var(--dim); font-weight: 600; margin-bottom: 5px; display: flex; justify-content: space-between; }
#legend .cseg { display: flex; gap: 3px; }
#legend .cseg button { border: 1px solid var(--line); background: transparent; color: var(--dim); border-radius: 6px; font-size: 11px; padding: 1px 6px; cursor: pointer; font-weight: 600; }
#legend .cseg button.on { color: #fff; border-color: rgba(114,232,255,0.5); background: rgba(114,232,255,0.14); }
#legend .t { align-items: center; }
#legend .bar { height: 9px; border-radius: 5px; }
#legend .ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10.5px; color: var(--dim); margin-top: 3px; }
#legend .extra { margin-top: 5px; color: var(--dim); display: flex; gap: 10px; flex-wrap: wrap; }
#legend .extra i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }

/* time bar */
#timebar { left: 50%; transform: translateX(-50%); bottom: 16px; width: min(760px, calc(100vw - 700px)); min-width: 460px; padding: 9px 12px; display: flex; gap: 12px; align-items: center; }
#play { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(114,232,255,0.5); background: rgba(114,232,255,0.14); cursor: pointer; display: grid; place-items: center; flex: none; }
#play svg { width: 18px; height: 18px; fill: #fff; }
#play .i-pause { display: none; } body.playing #play .i-pause { display: block; } body.playing #play .i-play { display: none; }
.tl { flex: 1; min-width: 0; }
.tlhead { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.tlhead b { font-family: var(--mono); font-weight: 400; font-size: 14px; color: #fff; }
.tlhead .dim { font-size: 12px; }
.wait { font-size: 11.5px; color: var(--yel); margin-left: auto; }
#track { position: relative; height: 6px; border-radius: 4px; background: rgba(255,255,255,0.1); margin-top: 7px; overflow: hidden; }
#fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #72e8ff, #c35ae0, #ffb454); border-radius: 4px; }
#segSpeed { width: 210px; flex: none; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.lab { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.lab.gate { font-size: 11px; color: #ffe2a0; font-weight: 600; margin: -18px 0 0 6px; text-shadow: 0 1px 6px #000, 0 0 2px #000; }
.lab.sea { font-size: 13px; color: rgba(200,225,245,0.5); font-weight: 700; letter-spacing: 0.3em; transform-origin: 0 0; margin: -8px 0 0 -30px; text-shadow: 0 1px 8px #000; }
.lab.mark { width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 2px solid var(--yel); box-shadow: 0 0 12px rgba(255,212,121,0.7); animation: pulse 1.8s infinite; }
.lab.markA { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--yel); }
.lab.drift { width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 2px; background: #ffe08a; transform-origin: center; box-shadow: 0 0 10px #ffd479; }
@keyframes pulse { 0% { opacity: 1; } 70% { opacity: 0.25; } 100% { opacity: 1; } }

#tip { position: fixed; z-index: 20; pointer-events: none; background: rgba(6, 12, 20, 0.9); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.5; max-width: 280px; }
#tip .mono { color: #fff; }
#toast { position: fixed; z-index: 30; left: 50%; top: 70px; transform: translateX(-50%); background: rgba(40, 30, 10, 0.92); border: 1px solid rgba(255,212,121,0.5); color: #ffe7b0; padding: 7px 14px; border-radius: 10px; font-size: 13px; }
.pill { position: fixed; z-index: 6; right: 16px; bottom: 16px; border-radius: 99px; border: 1px solid var(--line); background: var(--glass); color: #cfe3f5; padding: 8px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer; backdrop-filter: blur(10px); }
#credit { position: fixed; z-index: 4; right: 18px; bottom: 58px; font-size: 11px; color: #6c8196; text-align: right; }
#mtabs { display: none; }

dialog#about { max-width: 720px; width: calc(100vw - 32px); max-height: 86vh; overflow: auto; background: #0a1420; color: var(--txt); border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; line-height: 1.65; font-size: 13.5px; }
dialog#about::backdrop { background: rgba(0,0,0,0.6); }
dialog#about h2 { margin: 0 0 6px; font-size: 20px; }
dialog#about h3 { margin: 14px 0 4px; font-size: 14.5px; color: var(--acc); }
dialog#about ul { margin: 4px 0; padding-left: 18px; }
dialog#about li { margin: 3px 0; word-break: keep-all; }
dialog#about p { word-break: keep-all; }
dialog .x { position: sticky; float: right; top: 0; background: transparent; border: 0; font-size: 26px; color: var(--dim); cursor: pointer; }

#loading { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg); transition: opacity .5s; }
#loading.done { opacity: 0; pointer-events: none; }
.lb { text-align: center; color: var(--dim); font-size: 13px; }
.ring { width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(114,232,255,0.2); border-top-color: var(--acc); margin: 0 auto 12px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { width: 220px; height: 4px; 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 .2s; }
#err { position: fixed; z-index: 60; left: 0; right: 0; top: 0; background: #7a1a1a; color: #fff; padding: 6px 12px; font-size: 13px; }

@media (max-width: 1180px) {
  #timebar { width: calc(100vw - 32px); min-width: 0; left: 16px; transform: none; bottom: 16px; }
  #legend { bottom: 92px; }
  #right { bottom: 150px; }
  #credit { bottom: 84px; }
  .pill { bottom: 92px; right: 344px; }
}
@media (max-width: 760px) {
  html, body { font-size: 13px; }
  #brand { left: 14px; top: 10px; }
  #brand h1 { font-size: 23px; }
  #brand .kicker { font-size: 10px; }
  #brand .sub { display: none; }
  #viewbar { top: auto; left: 12px; transform: none; bottom: 176px; padding: 4px; }
  #viewbar .seg { width: 104px; }
  .chip span { padding: 4px 6px; font-size: 11px; }
  #cases, #right > .panel { position: fixed; left: 8px; right: 8px; width: auto; top: auto; bottom: 64px; max-height: 46vh; overflow: auto; z-index: 8; }
  #right { position: static; width: auto; }
  #cases, #release, #stats { display: none; }
  body[data-p=cases] #cases, body[data-p=release] #release, body[data-p=stats] #stats { display: block; }
  #caseList { grid-template-columns: 1fr 1fr; }
  #legend { left: 12px; right: auto; width: 200px; bottom: 214px; padding: 6px 9px; font-size: 10.5px; }
  #legend .extra { display: none; }
  #timebar { left: 8px; right: 8px; width: auto; bottom: 64px; padding: 7px 9px; gap: 8px; flex-wrap: wrap; }
  body[data-p=cases] #timebar, body[data-p=release] #timebar, body[data-p=stats] #timebar { display: none; }
  #segSpeed { width: 100%; order: 3; }
  #play { width: 34px; height: 34px; }
  #mtabs { display: flex; position: fixed; left: 8px; right: 8px; bottom: 10px; z-index: 9; gap: 4px; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 4px; backdrop-filter: blur(12px); }
  #mtabs button { flex: 1; border: 0; background: transparent; padding: 9px 4px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--dim); }
  #mtabs button.on { background: rgba(114,232,255,0.16); color: #fff; }
  .pill { right: 12px; top: 12px; bottom: auto; padding: 6px 10px; font-size: 11.5px; }
  #credit { display: none; }
  body[data-p=cases] #legend, body[data-p=release] #legend, body[data-p=stats] #legend,
  body[data-p=cases] #viewbar, body[data-p=release] #viewbar, body[data-p=stats] #viewbar { display: none; }
}
