:root {
  --bg: #f6efe2;
  --panel: #fffaf1;
  --ink: #3b2f26;
  --muted: #86786a;
  --line: #e3d6c1;
  --accent: #c8642c;
  --ok: #3b8a55;
  --bad: #c62f2f;
  --ref: #2a7fb8;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
button, select, input { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 5px 10px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.num { width: 4.2em; }

.top {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5;
}
.top h1 { font-size: 17px; margin: 0; }
.tabs { display: flex; gap: 4px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.status { margin-left: auto; color: var(--muted); font-size: 13px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 50px); }
.side { border-right: 1px solid var(--line); padding: 10px 12px; background: var(--panel); overflow: auto; max-height: calc(100vh - 50px); position: sticky; top: 50px; }
.side h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li button {
  width: 100%; text-align: left; border: 0; background: none; padding: 4px 6px; border-radius: 6px;
  display: flex; justify-content: space-between; gap: 6px; font-size: 13px;
}
.list li button:hover { background: var(--bg); }
.list li button.on { background: var(--ink); color: var(--panel); }
.list .count { color: var(--muted); font-size: 12px; }
.list li button.on .count { color: inherit; opacity: .8; }
.list .group { font-size: 11px; color: var(--muted); padding: 6px 6px 2px; }
.hint { font-size: 12px; color: var(--muted); }

main { padding: 14px 18px 40px; min-width: 0; }
.flow { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 12px 8px 30px; margin: 0 0 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.anim-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; }
.anim-head h2 { margin: 0; font-size: 20px; }
.anim-head .meta { color: var(--muted); font-size: 13px; }
.common { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 14px; }
.common summary { cursor: pointer; font-weight: 600; }
.common .block { margin: 8px 0; }
.common .block b { font-size: 12px; color: var(--accent); }
.common pre, .card pre {
  white-space: pre-wrap; word-break: break-word; margin: 4px 0; font-size: 12.5px; line-height: 1.45;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.card.dragover { outline: 3px dashed var(--accent); }
.card header { display: flex; align-items: center; gap: 8px; }
.card header h3 { margin: 0; font-size: 16px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--ref); color: #fff; }
.badge.warn { background: var(--bad); }
.badge.ok { background: var(--ok); }
.card .pose { font-size: 13px; margin: 0; }
.card pre { max-height: 180px; overflow: auto; }
.card .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.attach { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.attach figure { margin: 0; width: 92px; }
.attach img, .attach .missing { width: 92px; height: 92px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; display: block; }
.attach .missing { display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; padding: 4px; }
.attach figcaption { margin-top: 2px; line-height: 1.25; word-break: break-all; }
.thumb { display: flex; gap: 10px; align-items: center; }
.thumb img, .thumb .slot {
  width: 120px; height: 120px; object-fit: contain; border-radius: 8px; border: 1px dashed var(--line);
  background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 16px 16px;
}
.thumb .slot { display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 12px; padding: 6px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.set-title { font-size: 16px; margin-right: 6px; }
#scrub { width: 220px; }
.stage-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.stages { display: flex; gap: 12px; flex-wrap: wrap; }
.stages figure, .app-wrap figure { margin: 0; }
figcaption { font-size: 12px; color: var(--muted); margin-top: 3px; }
canvas { display: block; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
#stage, #stage2 { width: 480px; height: 480px; }
.app-wrap h3 { margin: 0 0 6px; font-size: 14px; }
.app-wrap figure { margin-bottom: 8px; }
.legend { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.sw { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 3px; vertical-align: middle; }
.sw.ref { background: var(--ref); } .sw.cur { background: var(--ok); } .sw.bad { background: var(--bad); }
.sw.prev { background: #e0507a; } .sw.nextc { background: #3a7be0; }

.summary { margin: 12px 0 6px; padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.summary.bad { border-color: var(--bad); }
.summary.good { border-color: var(--ok); }
.chart { width: 100%; height: 110px; }
.table-wrap { overflow: auto; max-height: 520px; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel); z-index: 1; font-weight: 600; }
td:nth-child(2), th:nth-child(2), td.l, th.l { text-align: left; }
tr.cur td { background: #fbe9d4; }
tr.warn td.w { color: var(--bad); font-weight: 600; }
td.over { color: var(--bad); font-weight: 600; }
tbody tr { cursor: pointer; }

.drop-hint {
  position: fixed; inset: 12px; border: 4px dashed var(--accent); border-radius: 18px;
  background: rgba(246, 239, 226, .85); display: grid; place-items: center; font-size: 22px; z-index: 20;
}
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 8px 14px; border-radius: 10px; z-index: 30; font-size: 14px; }

[hidden] { display: none !important; }
.sw.spec { background: var(--accent); }
#compareTable th:first-child, #compareTable td:first-child, #compareTable th:last-child { text-align: left; }

/* The page also runs as a static build (build-static.mjs) and on a phone. */
html, body { overflow-x: hidden; }
.static-note { margin: 0; padding: 6px 16px; font-size: 13px; background: #fbe9d4; border-bottom: 1px solid var(--line); }
.cards { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
#stage, #stage2 { width: min(480px, 100%); height: auto; aspect-ratio: 1; }
.stages figure { flex: 1 1 280px; max-width: 480px; }
#appRoom { width: min(372px, 100%); height: auto; aspect-ratio: 372 / 300; }
#appWheel { width: min(340px, 100%); height: auto; aspect-ratio: 1; }
.app-wrap { min-width: 0; flex: 1 1 280px; max-width: 380px; }
.side-toggle { display: none; }
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; position: static; }
  .status { margin-left: 0; width: 100%; }
  .layout { grid-template-columns: 1fr; min-height: 0; }
  .side { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-toggle { display: block; width: 100%; margin: 4px 0; }
  .side.collapsed section { display: none; }
  main { padding: 12px; }
  #scrub { width: 100%; order: 10; }
  .flow { padding-left: 24px; }
}

/* 이어 보기 */
.seq-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.seq-left { flex: 1 1 340px; min-width: 0; }
.seq-right { flex: 0 1 400px; min-width: 0; }
.seq-list { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 4px; }
.seq-item { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.seq-name { font-weight: 600; flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.seq-buttons { display: flex; gap: 4px; }
.seq-buttons button { padding: 2px 8px; }
.seq-trans { font-size: 12.5px; padding: 3px 10px 3px 22px; color: var(--muted); }
.seq-trans.bad { color: var(--bad); }
.seq-trans.ok { color: var(--ok); }
#seqCanvas { width: min(400px, 100%); height: auto; aspect-ratio: 1; }
.seq-scrub { width: min(400px, 100%); }
.seq-now { font-size: 13px; min-height: 2.6em; }
#seqAdd { max-width: 100%; }
.seq-trans.wrap { color: var(--muted); font-style: italic; }
