:root { --bg: #0e1218; --panel: #161c25; --line: #2a3340; --text: #e6ebf2; --muted: #8a97a8; --accent: #4f8cff; --ok: #3ddc84; --warn: #f5b942; --error: #ff5a5a; --bar: 44px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: #1f2936; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.on { background: #2b3d5d; border-color: var(--accent); }
select, input[type=text], textarea { background: #0f1520; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
textarea { width: 100%; resize: vertical; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.grow { flex: 1; }
kbd { font: 11px ui-monospace, Menlo, monospace; background: #1f2936; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted); }

.bar { height: var(--bar); display: flex; align-items: center; gap: 12px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.bar .brand { font-size: 15px; }
.bar label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.bar select { max-width: 340px; }

.layout { height: calc(100vh - var(--bar)); display: grid; grid-template-columns: 240px 1fr 320px; }
body.wide .layout { grid-template-columns: 0 1fr 0; }
body.wide .nav, body.wide .side { display: none; }

/* 왼쪽: 계층(대상 ▸ 동작) 또는 판정 목록 */
.nav { overflow: auto; border-right: 1px solid var(--line); padding: 8px; }
.nav details { margin: 2px 0; }
.nav summary { cursor: pointer; padding: 5px 6px; border-radius: 6px; list-style: none; display: flex; gap: 6px; align-items: center; }
.nav summary::-webkit-details-marker { display: none; }
.nav summary::before { content: '▸'; color: var(--muted); font-size: 11px; width: 10px; }
.nav details[open] > summary::before { content: '▾'; }
.nav summary:hover { background: #1b2330; }
.nav .cnt { color: var(--muted); font-size: 12px; margin-left: auto; }
.nav .kind { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 4px 6px 4px 22px; }
.nav .kind:hover { background: #1b2330; }
.nav .kind.on { background: #2b3d5d; }
.nav .kind .sub { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.nav .item { display: block; width: 100%; text-align: left; border-radius: 8px; padding: 8px; margin: 4px 0; background: #121923; border: 1px solid var(--line); }
.nav .item.on { border-color: var(--accent); background: #1d2a40; }
.nav .item.done { opacity: .6; }
.nav .item .q { font-weight: 600; }
.nav .item .w { color: var(--muted); font-size: 12px; margin-top: 2px; }
.nav .item .st { font-size: 12px; margin-top: 4px; }
.nav h3 { margin: 6px 6px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.nav .empty { color: var(--muted); padding: 10px 6px; }

/* 가운데: 화면 + 타임라인 */
.center { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; min-height: 0; overflow: hidden; }
.viewTabs { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.viewTabs button { padding: 3px 10px; font-size: 13px; }
#gameStage { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.stageCtl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); overflow: hidden; }
.stageCtl select { max-width: 260px; text-overflow: ellipsis; }
.stageCtl label { display: flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }
.stageCtl .grp { display: flex; align-items: center; gap: 6px; }
.viewer { position: relative; min-height: 0; background: #0b1018; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; left: 10px; top: 8px; font-size: 13px; color: #cfd8e3; text-shadow: 0 1px 2px #000; pointer-events: none; white-space: pre-line; }
.hud b { color: #fff; font-size: 15px; }

.timeline { border-top: 1px solid var(--line); background: var(--panel); }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.transport label { display: flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }
.transport button { min-width: 36px; padding: 4px 8px; }
.transport button.main { min-width: 84px; font-weight: 600; }
.transport #scrub { flex: 1 1 160px; min-width: 120px; accent-color: var(--accent); }
.transport .counter { font-size: 14px; color: #fff; min-width: 64px; text-align: center; }
.transport .sep { width: 1px; height: 20px; background: var(--line); }

/* 타임라인 격자: 왼쪽 레이어 이름 열 + 칸 열. 머리 줄은 번호·시간, 그 아래 합성·몸·덧그림 행, 마지막 사건 행 */
.tl { overflow: auto; max-height: 50vh; }
.tl table { border-collapse: separate; border-spacing: 0; }
.tl th, .tl td { padding: 0; border-right: 1px solid #1d2531; border-bottom: 1px solid #1d2531; }
.tl th.lay { position: sticky; left: 0; z-index: 2; background: var(--panel); text-align: left; padding: 0 10px; font-weight: 500; font-size: 12px; color: var(--muted); min-width: 96px; white-space: nowrap; }
.tl thead th { position: sticky; top: 0; z-index: 3; background: var(--panel); }
.tl thead th.lay { z-index: 4; }
.tl .fh { width: 84px; min-width: 84px; text-align: center; font-weight: 500; font-size: 12px; cursor: pointer; padding: 4px 2px; vertical-align: top; }
.tl .fh .n { font-size: 13px; color: #fff; }
.tl .fh .ms { color: var(--muted); font-size: 11px; }
.tl .fh .nt { color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
.tl .fh.on { background: #2b3d5d; }
.tl .fh.hit .n::after { content: ' ●'; color: var(--warn); }
.tl td.cel { width: 84px; height: 56px; cursor: pointer; background: #10151d; }
.tl td.cel canvas { width: 84px; height: 56px; display: block; image-rendering: pixelated; }
.tl td.cel.on { background: #1b2a44; box-shadow: inset 0 0 0 2px var(--accent); }
.tl td.cel.empty { background: repeating-linear-gradient(45deg, #10151d 0 6px, #141b26 6px 12px); }
.tl td.ev { height: 22px; text-align: center; font-size: 11px; color: var(--warn); cursor: pointer; }
.tl td.ev.on { background: #1b2a44; }
.tl td.ev .bt { color: #9fc9ff; }
.tl .playhead { background: #1b2a44; }

/* 오른쪽: 판정 + 속성 */
.side { overflow: auto; border-left: 1px solid var(--line); padding: 10px 12px; }
.side h2 { font-size: 13px; color: var(--muted); margin: 10px 0 6px; font-weight: 600; }
.side h2:first-child { margin-top: 2px; }
.judge { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #121923; margin-bottom: 10px; }
.judge .q { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.judge .why { color: var(--muted); font-size: 12px; margin-bottom: 8px; white-space: pre-line; }
.judge .btns { display: flex; gap: 8px; margin: 6px 0; }
.judge .btns button { flex: 1; }
.judge button.yes.on { background: #1d4a2e; border-color: var(--ok); }
.judge button.no.on { background: #5a2424; border-color: var(--error); }
.judge input { width: 100%; margin-top: 4px; }
.judge .media img { width: 100%; border-radius: 6px; margin-top: 8px; image-rendering: pixelated; background: #0b1018; }
.judge .go { display: block; margin-top: 8px; font-size: 12px; color: #9fc9ff; }
.judge button.go { width: 100%; color: var(--text); font-size: 13px; background: #243550; border-color: var(--accent); }
.info { font-size: 13px; }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 4px 0; }
.info dt { color: var(--muted); white-space: nowrap; }
.info dd { margin: 0; word-break: break-all; }
.checks { margin: 0; padding-left: 16px; }
.checks li { font-size: 12px; margin: 2px 0; }
.checks .error { color: var(--error); } .checks .warn { color: var(--warn); } .checks .ok { color: var(--ok); } .checks .info { color: var(--muted); }
.copyBar { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
textarea.out { height: 72px; margin-top: 6px; font-size: 12px; }
.err { color: var(--error); white-space: pre-line; }

@media (max-width: 1100px) { .layout { grid-template-columns: 200px 1fr 280px; } }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; height: auto; } .nav { max-height: 30vh; } .viewer { height: 46vh; } }
