/* ============================================================================
   GLB Action Inspector — DESIGN.md (Genesis) 적용

   DESIGN.md 는 라이트 테마 시스템이다. 이 툴은 3D 뷰포트를 가지므로
   패널은 시스템 그대로 밝게 가고, 뷰포트만 중성 회색으로 둔다.
   (배경에 색이 섞이면 모델의 실제 색을 판단할 수 없다 — DCC 툴의 관행)

   대비 검증
     Text Secondary #6B6B6B  5.33:1  본문 통과
     Neutral       #9C9C9C   2.75:1  → 비활성·장식에만 사용
     Success/Warning/Error 원색은 흰 배경에서 2.1~3.8:1 로 글자에 못 쓴다.
     명도만 낮춘 -ink 변형을 따로 두고, 원색은 채움·보더·표시등에만 쓴다.
     칩 글자는 전부 4.6:1 이상 (실제 렌더 색으로 측정).
   ========================================================================== */

:root {
  /* ── DESIGN.md 원본 팔레트 ─────────────────────────────────────────────── */
  --primary:        #6366F1;
  --primary-hover:  #4F46E5;
  --neutral:        #9C9C9C;   /* 비활성·장식 전용 (본문 대비 미달) */
  --bg:             #FAFAFA;
  --surface:        #FFFFFF;
  --text:           #0A0A0A;
  --text-2:         #6B6B6B;
  --border:         #E8E8EC;
  --success:        #10B981;
  --warning:        #F59E0B;
  --error:          #EF4444;

  /* ── 글자용 파생값 ──────────────────────────────────────────────────────
     색조(H)·채도(S)는 원색 그대로 두고 명도만 낮춘 값.
     칩 글자는 흰 배경이 아니라 아래 tint 위에 올라가므로 tint 기준으로 뽑았다.
     (흰 배경 기준으로 뽑으면 tint 위에서 4.1:1 로 떨어진다 — 실측으로 확인) */
  --success-ink:    #0B7D57;   /* tint 위 4.60:1 · 흰 배경 5.14:1 */
  --warning-ink:    #996307;   /* tint 위 4.62:1 · 흰 배경 5.07:1 */
  --error-ink:      #C23737;   /* tint 위 4.62:1 · 흰 배경 5.39:1 */

  /* ── 연한 배경 (원색 12%) ──────────────────────────────────────────────── */
  --primary-tint:   #ECEDFD;
  --success-tint:   #E2F7F0;
  --warning-tint:   #FEF3E2;
  --error-tint:     #FDE9E9;

  /* ── 3D 뷰포트 (DESIGN.md 범위 밖 · 기능 요구) ─────────────────────────── */
  --viewport:       #5F5F64;

  /* ── 간격: 4px 그리드 ──────────────────────────────────────────────────── */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* ── 라운드 ────────────────────────────────────────────────────────────── */
  --r-chip:   4px;   /* 태그·배지·인라인 코드 */
  --r-ctrl:   6px;   /* 버튼·입력·셀렉트 */
  --r-panel:  8px;   /* 패널·드롭다운 */
  --r-card:  12px;   /* 카드·모달 */
  --r-pill: 9999px;

  /* ── 컨트롤 높이 — DESIGN.md 버튼 사이즈 규격 ───────────────────────────
     같은 줄에 놓이는 컨트롤은 반드시 같은 높이를 써야 한다.
     높이를 padding + line-height 에 맡기면 select 39px, input 43px 처럼
     서로 어긋난다(실측). height 로 못 박고 세로 패딩은 0 으로 둔다. */
  --ctrl-sm: 32px;
  --ctrl-md: 38px;
  --ctrl-lg: 44px;

  /* ── 타이포 ────────────────────────────────────────────────────────────── */
  --font-display: "General Sans", -apple-system, BlinkMacSystemFont, "Pretendard", sans-serif;
  --font-body:    "DM Sans", -apple-system, BlinkMacSystemFont, "Pretendard",
                  "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --t-subhead:  24px;
  --t-section:  16px;
  --t-body:     15px;
  --t-small:    13px;
  --t-caption:  12px;
  --t-overline: 11px;

  /* ── 그림자: 정적 요소엔 쓰지 않는다. hover / focus 전용 ───────────────── */
  --lift:      0 8px 30px rgba(0, 0, 0, 0.08);
  --lift-btn:  0 4px 12px rgba(99, 102, 241, 0.35);
  --ring:      0 0 0 3px rgba(99, 102, 241, 0.12);

  /* dropdown < sticky < backdrop < modal < toast < tooltip */
  --z-sticky: 10;
  --z-overlay: 20;
  --z-modal: 40;
  --z-toast: 50;
  --z-tip: 60;

  /* JS 는 -stored 만 인라인으로 쓴다. 실제 폭(--w-left/right)은 아래에서
     계산한다 — 인라인 변수는 접힘 규칙보다 우선해서, JS 가 실제 폭을 직접
     쓰면 접어도 폭이 그대로 남는다. */
  --w-left-stored:  304px;
  --w-right-stored: 304px;
  --resizer: 5px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--t-small);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, select { font: inherit; color: inherit; }
::selection { background: var(--primary-tint); }

.kv dd, .chip b, .tp-time, .clip-meta, .track-info,
.gauge b, .morph-row b, .range b {
  font-variant-numeric: tabular-nums;
}

/* DESIGN.md: focus 는 그림자가 아니라 3px 인디고 링 */
:where(button, a, input, select, [tabindex]):focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.ico { width: 16px; height: 16px; flex: none; display: block; color: currentColor; }

/* ── 스크롤바 ──────────────────────────────────────────────────────────────
   한 곳에서만 정의한다. 컴포넌트마다 따로 쓰면 두께가 어긋나고,
   thumb 테두리를 컨테이너 색으로 칠하는 방식은 배경이 다른 곳(코드블록)에서
   흰 줄이 비친다. 투명 테두리 + background-clip 으로 배경과 무관하게 만든다. */
/* 표준 속성(scrollbar-width / scrollbar-color)을 하나라도 지정하면 크롬이
   표준 스크롤바로 전환하면서 ::-webkit-scrollbar 를 통째로 무시한다.
   그래서 두 체계를 섞지 않는다 — 웹킷은 아래 ::-webkit- 규칙(8px),
   그걸 지원하지 않는 파이어폭스만 표준 속성을 쓴다. */
@supports not selector(::-webkit-scrollbar) {
  .panel, .modal-body, .issues, .clip-list, .track-list, .morph-list, .codeblock pre {
    scrollbar-width: thin;
    scrollbar-color: #D5D5DB transparent;
  }
}
.panel::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.issues::-webkit-scrollbar,
.clip-list::-webkit-scrollbar,
.track-list::-webkit-scrollbar,
.morph-list::-webkit-scrollbar,
.codeblock pre::-webkit-scrollbar { width: 8px; height: 8px; }

.panel::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.issues::-webkit-scrollbar-thumb,
.clip-list::-webkit-scrollbar-thumb,
.track-list::-webkit-scrollbar-thumb,
.morph-list::-webkit-scrollbar-thumb,
.codeblock pre::-webkit-scrollbar-thumb {
  background: #D5D5DB;
  border: 2px solid transparent;   /* 실제로 보이는 두께는 4px */
  background-clip: content-box;
  border-radius: var(--r-pill);
}
.panel:hover::-webkit-scrollbar-thumb,
.modal-body:hover::-webkit-scrollbar-thumb,
.issues:hover::-webkit-scrollbar-thumb,
.clip-list:hover::-webkit-scrollbar-thumb,
.track-list:hover::-webkit-scrollbar-thumb,
.codeblock pre:hover::-webkit-scrollbar-thumb { background: #BFBFC8; background-clip: content-box; }

/* ─────────────────────────────── layout ─────────────────────────────────── */

#app {
  --w-left:  var(--w-left-stored);
  --w-right: var(--w-right-stored);
  position: relative;        /* 폭 조절 손잡이의 기준 */
  display: grid;
  grid-template-columns: var(--w-left) minmax(0, 1fr) var(--w-right);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas:
    "top  top    top"
    "left stage  right";
  height: 100%;
}

#topbar     { grid-area: top; }
#panelLeft  { grid-area: left;  border-right: 1px solid var(--border); }
#stage      { grid-area: stage; }
#panelRight { grid-area: right; border-left: 1px solid var(--border); }

/* ─────────────────────────────── topbar ─────────────────────────────────── */

#topbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-sticky);
}

.brand { display: flex; align-items: baseline; gap: var(--s-2); user-select: none; }
.brand-mark {
  font-family: var(--font-display);
  font-size: var(--t-small);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.brand-text {
  font-size: var(--t-caption);
  color: var(--text-2);
  letter-spacing: -0.01em;
}

.topbar-actions { display: flex; align-items: center; gap: var(--s-2); }
.topbar-stats { margin-left: auto; display: flex; gap: var(--s-4); }
.topbar-right { display: flex; gap: var(--s-1); }

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--text-2);
  cursor: help;
}
.chip b { color: var(--text); font-weight: 500; }
.chip i { font-style: normal; }

/* ──────────────────────────── controls ──────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--ctrl-sm);
  padding: 0 var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-ctrl);
  color: var(--text);
  font-size: var(--t-small);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 200ms ease-out, background 200ms ease-out,
              border-color 200ms ease-out, box-shadow 200ms ease-out, color 200ms ease-out;
}
.btn:hover  { transform: translateY(-1px); background: var(--bg); border-color: #DADAE0; }
.btn:active { transform: none; }
.btn:disabled { opacity: 1; color: var(--neutral); cursor: not-allowed; }
.btn:disabled:hover { transform: none; background: var(--surface); border-color: var(--border); }

/* DESIGN.md: 한 화면에 채워진 인디고 버튼은 하나만 */
.btn-primary {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #FFFFFF;
}
.btn-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: var(--lift-btn);
}

.btn-ghost, .btn-code { background: transparent; border-color: transparent; }
.btn-ghost:hover, .btn-code:hover { background: var(--bg); border-color: var(--border); }
.btn-icon {
  width: var(--ctrl-sm); padding: 0;
  background: transparent; border-color: transparent;
}
.btn-icon:hover { background: var(--bg); border-color: var(--border); }
.btn-block { width: 100%; height: var(--ctrl-md); margin-top: var(--s-3); }

select, input[type="number"], input[type="text"] {
  height: var(--ctrl-md);
  padding: 0 14px;              /* DESIGN.md: 가로 14px */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-ctrl);
  font-size: 14px;
  color: var(--text);
  min-width: 0;
  transition: border-color 200ms ease-out, box-shadow 200ms ease-out;
}
select:hover, input[type="number"]:hover { border-color: #DADAE0; }
::placeholder { color: var(--text-2); }
.select-wrap select { max-width: 272px; }

.field { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.field > span { color: var(--text-2); font-size: var(--t-caption); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }

/* 분절 컨트롤 — 칩 문법(pill)을 따른다 */
.mode-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.mode-row .seg { flex: 1 1 auto; margin-bottom: 0; }
.mode-row .help { margin-left: 0; }

.seg {
  display: flex;
  gap: var(--s-1);
  margin-bottom: var(--s-3);
}
.seg-btn {
  flex: 1;
  height: var(--ctrl-sm);
  padding: 0 var(--s-3);
  background: #F1F1F4;
  border: 0;
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: var(--t-caption);
  font-weight: 500;
  cursor: pointer;
  transition: background 200ms ease-out, color 200ms ease-out;
}
.seg-btn:hover { background: #E8E8EC; color: var(--text); }
.seg-btn.is-on { background: var(--primary-hover); color: #FFFFFF; }

/* 토글 — DESIGN.md 체크박스 규칙(20px, rounded-full, 인디고) */
/* 셀렉트 줄 바로 아래에 토글이 붙으면 한 덩어리로 보인다 (실측 0px) */
.row-2 + .switch { margin-top: var(--s-3); }

.switch {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 3px 0;
  cursor: pointer;
  color: var(--text);
}
.switch input { position: absolute; opacity: 0; width: 0; }
.switch span {
  width: 34px; height: 20px; flex: none;
  background: #E2E2E6;
  border-radius: var(--r-pill);
  position: relative;
  transition: background 200ms ease-out;
}
.switch span::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: var(--r-pill);
  background: var(--surface);
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }
.switch input:disabled + span { background: #F1F1F4; }
.switch input:disabled ~ * { color: var(--neutral); }

/* 슬라이더 */
.range { display: block; margin: var(--s-3) 0 var(--s-1); }
.range > span {
  display: flex; justify-content: space-between;
  color: var(--text-2); font-size: var(--t-caption); margin-bottom: var(--s-2);
}
.range > span b { color: var(--text); font-family: var(--font-mono); font-weight: 400; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  border-radius: var(--r-pill);
  background: #E2E2E6;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: var(--r-pill);
  background: var(--primary);
  border: 0;
  transition: box-shadow 200ms ease-out;
}
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: var(--ring); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: var(--r-pill);
  background: var(--primary); border: 0;
}

/* ──────────────────────────── panels ────────────────────────────────────── */

.panel {
  background: var(--surface);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.card { flex: 0 0 auto; border-bottom: 1px solid var(--border); }
.card:last-child { border-bottom: 0; }
.card-grow { display: flex; flex-direction: column; min-height: 0; }

/* 패널 섹션 헤더 = Overline 11px uppercase */
.card-title {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin: 0;
  padding: var(--s-4) var(--s-4) var(--s-2);
  font-size: var(--t-overline);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.card-title em, .card-title .badge { margin-left: auto; }
.card-title em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-2);
  max-width: 55%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-body { padding: 0 var(--s-4) var(--s-4); }

/* 상태 칩 — pill, 연한 배경 + 짙은 글자 */
.badge {
  padding: 2px var(--s-3);
  border-radius: var(--r-pill);
  background: #F1F1F4;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--t-overline);
  letter-spacing: 0;
  text-transform: none;
}
.badge-ok   { background: var(--success-tint); color: var(--success-ink); }
.badge-warn { background: var(--warning-tint); color: var(--warning-ink); }
.badge-err  { background: var(--error-tint);   color: var(--error-ink); }

.hint { color: var(--text-2); font-size: var(--t-small); margin: var(--s-1) 0 var(--s-3); line-height: 1.6; }

/* 보더가 있는 목록의 빈 상태 — 텍스트가 테두리에 붙지 않도록 자체 여백을 준다 */
.clip-list > .hint,
.track-list > .hint,
.morph-list > .hint {
  margin: 0;
  padding: var(--s-4);
  text-align: center;
}
.hint b { color: var(--text); font-weight: 500; }

/* 수치 목록 — DESIGN.md 리스트 규칙: 1px 구분선, space-between */
.kv { margin: 0; font-size: var(--t-small); }
.kv-row {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: 0; }
.kv dt { flex: 0 0 auto; white-space: nowrap; color: var(--text-2); }
.kv dd {
  flex: 1 1 auto;
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  text-align: right;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.help {
  display: inline-block;
  width: 13px;
  margin-left: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--neutral);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  transition: color 200ms ease-out;
}
.help:hover { color: var(--primary); }

/* ── 검사 결과 ───────────────────────────────────────────────────────────── */

.issues {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
}
.issues > * { flex: 0 0 auto; }

/* grid 로 두면 <b> 앞뒤 텍스트 노드가 각각 grid item 이 되어 글자가 쪼개진다.
   심각도 칩은 absolute 로 띄우고 본문은 흘린다. */
.issue {
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--t-small);
  line-height: 1.55;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.issue:last-child { border-bottom: 0; }
.issue::after { content: ""; display: block; clear: both; }
/* 심각도 칩을 float 로 둔다. absolute 로 자리를 비워 두면 304px 패널에서
   본문이 190px 남짓한 좁은 기둥이 되어 네 줄씩 쪼개진다. float 면 첫 줄만
   칩을 피해 가고 나머지 줄은 전체 폭을 쓴다. */
.issue::before {
  float: left;
  width: 38px;
  margin: 1px var(--s-2) 0 0;
  padding: 1px 0;
  border-radius: var(--r-chip);
  font-size: var(--t-overline);
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  background: #F1F1F4;
  color: var(--text-2);
}
.issue-err::before  { content: "오류"; background: var(--error-tint);   color: var(--error-ink); }
.issue-warn::before { content: "경고"; background: var(--warning-tint); color: var(--warning-ink); }
.issue-ok::before   { content: "정상"; background: var(--success-tint); color: var(--success-ink); }
.issue-info::before { content: "참고"; }
.issue-empty { padding: var(--s-4); text-align: center; }
.issue-empty::before { content: none; }
.issue b { color: var(--text); font-weight: 500; }
/* 판정 근거 — 본문보다 확실히 뒤로 물러나야 한다 */
.issue-basis {
  display: block;
  margin-top: 3px;
  color: var(--neutral);
  font-size: var(--t-overline);
  line-height: 1.5;
}
.issue code {
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  padding: 1px 5px;
  border-radius: var(--r-chip);
  background: #F1F1F4;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* ── 요약 ────────────────────────────────────────────────────────────────── */

.verdict {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  font-size: var(--t-small);
  line-height: 1.55;
}
.verdict-mark {
  flex: none;
  padding: 2px var(--s-3);
  border-radius: var(--r-pill);
  background: #F1F1F4;
  color: var(--text-2);
  font-size: var(--t-overline);
  font-weight: 500;
}
.verdict-text { color: var(--text-2); }
.v-ok   .verdict-mark { background: var(--success-tint); color: var(--success-ink); }
.v-warn .verdict-mark { background: var(--warning-tint); color: var(--warning-ink); }
.v-err  .verdict-mark { background: var(--error-tint);   color: var(--error-ink); }

.gauges { display: flex; flex-direction: column; gap: var(--s-2); }
.gauges > * { flex: 0 0 auto; }
.gauge > span {
  display: flex; justify-content: space-between; gap: var(--s-2);
  font-size: var(--t-caption); color: var(--text-2); margin-bottom: 5px;
}
.gauge > span b { color: var(--text); font-family: var(--font-mono); font-weight: 400; }
.gauge-bar { height: 4px; border-radius: var(--r-pill); background: #F1F1F4; overflow: hidden; }
/* width 대신 scaleX — 레이아웃을 다시 계산하지 않는다 */
.gauge-fill {
  height: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.gauge-fill.g-ok   { background: var(--neutral); }
.gauge-fill.g-warn { background: var(--warning); }
.gauge-fill.g-err  { background: var(--error); }

/* ──────────────────────────── stage ─────────────────────────────────────── */

#stage { position: relative; background: var(--viewport); overflow: hidden; }
#canvasHost { position: absolute; inset: 0; }
#canvasHost canvas { display: block; width: 100%; height: 100%; }

.dropzone {
  position: absolute; inset: 0;
  z-index: var(--z-overlay);
  display: none;
  align-items: center; justify-content: center;
  padding: var(--s-6);
  text-align: center;
  background: var(--bg);
}
.dropzone.is-empty, .dropzone.is-over { display: flex; }
.dropzone.is-over { background: var(--primary-tint); }

.dz-inner {
  border: 1px dashed #D5D5DB;
  border-radius: var(--r-card);
  padding: var(--s-10) var(--s-10);
  max-width: 480px;
  background: var(--surface);
  transition: border-color 200ms ease-out;
}
.dropzone.is-over .dz-inner { border-color: var(--primary); }
.dz-inner h3 {
  margin: 0 0 var(--s-2);
  font-family: var(--font-display);
  font-size: var(--t-subhead);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  text-wrap: balance;
}
.dz-inner p { margin: 0 0 var(--s-5); color: var(--text-2); font-size: var(--t-body); line-height: 1.7; }
.dz-inner code {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  padding: 1px 5px;
  border-radius: var(--r-chip);
  background: #F1F1F4;
  color: var(--text);
}
.dz-note { margin: var(--s-5) 0 0 !important; font-size: var(--t-caption); color: var(--neutral); }

.dz-cmd {
  margin: var(--s-4) 0 var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-panel);
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--t-small);
  line-height: 1.7;
  color: var(--text);
  text-align: left;
  white-space: pre;
  overflow-x: auto;
  user-select: all;
}

.loading {
  position: absolute; inset: 0;
  z-index: var(--z-overlay);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--s-3);
  background: rgba(250, 250, 250, 0.86);
}
.spinner {
  width: 24px; height: 24px;
  border-radius: var(--r-pill);
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-2); font-family: var(--font-mono); font-size: var(--t-caption); }

.toast {
  position: absolute;
  left: 50%; bottom: 96px;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  max-width: 78%;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-panel);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--lift);
  color: var(--text);
  font-size: var(--t-small);
  line-height: 1.5;
}
.toast[data-kind="err"] { border-color: var(--error); color: var(--error-ink); }

/* ──────────────────────────── transport ─────────────────────────────────── */

.transport {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-sticky);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.transport[data-disabled="true"] { opacity: 0.5; pointer-events: none; }

.tp-row-main { display: flex; align-items: center; gap: var(--s-2); }

.tp-btn {
  width: var(--ctrl-sm); height: var(--ctrl-sm);
  padding: 0;
  flex: none;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-ctrl);
  color: var(--text-2);
  cursor: pointer;
  transition: background 200ms ease-out, color 200ms ease-out, transform 200ms ease-out;
}
.tp-btn:hover { background: var(--bg); border-color: var(--border); color: var(--text); transform: translateY(-1px); }
.tp-play {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #FFFFFF;
}
.tp-play:hover { background: var(--primary); border-color: var(--primary); color: #FFFFFF; box-shadow: var(--lift-btn); }

.tp-time {
  display: flex; align-items: baseline; gap: 3px;
  padding: 0 var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--text);
  white-space: nowrap;
}
.tp-sep, .tp-unit { color: var(--text-2); }
.tp-frame { margin-left: var(--s-3); color: var(--text-2); }
.tp-frame b { color: var(--text); font-weight: 400; }

.tp-scrub { flex: 1 1 auto; min-width: 140px; position: relative; padding-top: 14px; }
.key-strip { position: absolute; top: 0; left: 0; width: 100%; height: 14px; display: block; }
.tp-scrub input[type="range"] { display: block; }

.tp-field { display: flex; align-items: center; gap: var(--s-2); white-space: nowrap; }
.tp-field > span { color: var(--text-2); font-size: var(--t-caption); }
.tp-field select { height: var(--ctrl-sm); padding: 0 var(--s-2); font-size: var(--t-caption); }

/* ──────────────────────────── clips ─────────────────────────────────────── */

.clip-list {
  display: flex;
  flex-direction: column;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  overflow-x: hidden;
}
.clip-list > * { flex: 0 0 auto; }

.clip {
  border-bottom: 1px solid var(--border);
  transition: background 200ms ease-out;
}
.clip:last-child { border-bottom: 0; }
.clip:hover { background: var(--bg); }
.clip.is-active { background: var(--primary-tint); }
/* 비중 0 — 재생 중이지만 자세에 반영되지 않는 상태 */
.clip.is-muted .clip-name,
.clip.is-muted .clip-meta,
.clip.is-muted .clip-play { opacity: 0.45; }

.clip-head {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: var(--s-2);
  align-items: center;
  padding: var(--s-2) var(--s-3);
  cursor: pointer;
}
.clip-play {
  width: 24px; height: 24px;
  padding: 0;                 /* 버튼 UA 기본 패딩(1px 6px) 제거 — 안 지우면
                                 콘텐츠 박스가 좁아져 아이콘이 가운데로 안 간다 */
  display: grid; place-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--r-chip);
  color: var(--text-2);
  cursor: pointer;
  transition: background 200ms ease-out, color 200ms ease-out;
}
.clip-play:hover { background: var(--surface); color: var(--text); }

.clip.is-playing .clip-play { color: var(--primary-hover); }
.clip-play .ico { width: 13px; height: 13px; }

.clip-name {
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.clip-meta {
  font-family: var(--font-mono);
  font-size: var(--t-overline);
  line-height: 1.5;
  color: var(--text-2);
  text-align: right;
  white-space: nowrap;
}
.clip-flag { display: inline-block; margin-left: 5px; font-size: 10px; color: var(--text-2); }
.clip-flag.f-warn { color: var(--warning-ink); }
.clip-flag.f-err  { color: var(--error-ink); }

.clip-weight { display: none; padding: 0 var(--s-3) var(--s-3); }
.clip-weight > span {
  display: flex; justify-content: space-between;
  font-size: var(--t-overline); color: var(--text-2); margin-bottom: var(--s-1);
}
.clip-weight > span b { font-family: var(--font-mono); font-weight: 400; color: var(--text); }
.mode-layer .clip-weight { display: block; }

/* 모프 */
.morph-list { display: flex; flex-direction: column; gap: var(--s-3); max-height: 260px; overflow-y: auto; }
.morph-list > * { flex: 0 0 auto; }
.morph-row > span {
  display: flex; justify-content: space-between; gap: var(--s-2);
  font-size: var(--t-caption); color: var(--text-2); margin-bottom: var(--s-1);
}
.morph-row > span i { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.morph-row > span b { font-family: var(--font-mono); font-weight: 400; color: var(--text); flex: none; }

/* 트랙 */
.track-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
}
.track-list > * { flex: 0 0 auto; }
.track {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-2);
  align-items: center;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--t-overline);
}
.track:last-child { border-bottom: 0; }
.track.t-bad { background: var(--error-tint); }
.track.t-bad .track-node { color: var(--error-ink); }
.track-node { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-node em { font-style: normal; color: var(--text-2); }
.track-info { color: var(--text-2); white-space: nowrap; }

/* ──────────────────────────── modal ─────────────────────────────────────── */

.modal {
  position: fixed; inset: 0;
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-6);
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 10, 10, 0.4); }

.modal-box {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: min(860px, 92vh);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--lift);
  overflow: hidden;
}
.modal-box-wide { width: min(1000px, 100%); }

.modal-head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--t-section);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.modal-head h2 em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: var(--t-small);
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-2);
}

.modal-body { flex: 1 1 auto; min-height: 0; padding: var(--s-6); overflow-y: auto; }

.tabs {
  flex: 0 0 auto;
  display: flex;
  padding: 0 var(--s-6);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: var(--s-3) 0;
  margin-right: var(--s-6);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: var(--t-small);
  font-weight: 500;
  white-space: nowrap;
  transition: color 200ms ease-out, border-color 200ms ease-out;
}
.tab:hover { color: var(--text); }
.tab.is-on { color: var(--primary-hover); border-bottom-color: var(--primary); }

/* 코드 블록 */
.codeblock {
  margin: 0 0 var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  overflow: hidden;
  background: var(--bg);
}
.codeblock-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--text-2);
}
.codeblock pre {
  margin: 0;
  padding: var(--s-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  line-height: 1.7;
  color: var(--text);
  tab-size: 2;
}
.btn-copy { height: 26px; padding: 0 var(--s-3); font-size: var(--t-caption); }
.btn-copy.is-done { background: var(--success-tint); border-color: var(--success-tint); color: var(--success-ink); }

/* 모달 안 산문 */
.doc h3 {
  margin: var(--s-6) 0 var(--s-3);
  font-family: var(--font-display);
  font-size: var(--t-body);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.doc h3:first-child { margin-top: 0; }
.doc p  { margin: 0 0 var(--s-3); font-size: var(--t-body); line-height: 1.75; color: var(--text-2); max-width: 68ch; text-wrap: pretty; }
.doc p b { color: var(--text); font-weight: 500; }
.doc ul, .doc ol { margin: 0 0 var(--s-3); padding-left: var(--s-5); line-height: 1.8; color: var(--text-2); }
.doc code {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  padding: 1px 5px;
  border-radius: var(--r-chip);
  background: #F1F1F4;
  color: var(--text);
  overflow-wrap: anywhere;
}
.doc table { width: 100%; border-collapse: collapse; margin: 0 0 var(--s-4); font-size: var(--t-small); }
.doc th, .doc td { padding: var(--s-2) var(--s-3) var(--s-2) 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.doc th { color: var(--text-2); font-weight: 500; font-size: var(--t-caption); }
.doc td { color: var(--text-2); }
.doc td:first-child { color: var(--text); }
.doc td code { white-space: nowrap; }

/* 버튼 옆에 붙는 옵션 토글 */
.zip-opt {
  padding: 0;
  font-size: var(--t-small);
  color: var(--text-2);
  white-space: nowrap;
}
.zip-opt b { font-family: var(--font-mono); font-weight: 400; color: var(--neutral); }

/* 문서 아래쪽의 실행 버튼 줄. 위 내용과 확실히 떨어뜨린다 */
.doc-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
}
.doc-actions .btn { height: var(--ctrl-md); min-width: 190px; }

/* 만드는 중 — 버튼 자체가 상태를 말한다 */
.btn.is-busy {
  cursor: progress;
  opacity: 1;
}
.btn.is-busy::before {
  content: "";
  width: 13px; height: 13px;
  margin-right: 2px;
  border-radius: var(--r-pill);
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  animation: spin 700ms linear infinite;
}
/* disabled 기본 스타일(회색 글자 · 흰 배경)이 진행 중 버튼을 덮지 않게 */
.btn-primary.is-busy,
.btn-primary.is-busy:hover,
.btn-primary:disabled.is-busy,
.btn-primary:disabled.is-busy:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #FFFFFF;
  box-shadow: none;
  transform: none;
}

/* GLB 를 빼고 받을 때, 어디에 무슨 이름으로 넣어야 하는지 */
.zip-hint {
  margin-left: auto;
  font-family: var(--font-body) !important;
  font-size: var(--t-small) !important;
  color: var(--text-2) !important;
  text-align: right;
  line-height: 1.5;
}
.zip-hint code {
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  padding: 1px 5px;
  border-radius: var(--r-chip);
  background: var(--warning-tint);
  color: var(--warning-ink);
  white-space: nowrap;
}
.zip-hint[hidden] { display: none; }
/* 바로 앞 요소가 이미 아래 선을 그으면 여기서 또 긋지 않는다 (선이 두 줄로 보였다) */
.note:has(+ .doc-actions) { border-bottom: 0; }

.note {
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.7;
  color: var(--text-2);
  font-size: var(--t-small);
}
.note::after { content: ""; display: block; clear: both; }
.note::before {
  float: left;
  margin: 2px var(--s-3) 0 0;
  width: 40px;
  padding: 1px 0;
  border-radius: var(--r-chip);
  background: #F1F1F4;
  color: var(--text-2);
  font-size: var(--t-overline);
  font-weight: 500;
  text-align: center;
}
/* 모델에 대한 판정이 아니라 코드를 붙일 때의 절차 안내 */
.note-step::before { content: "안내"; background: var(--primary-tint); color: var(--primary-hover); }
.note-ok::before   { content: "정상"; background: var(--success-tint); color: var(--success-ink); }
.note-info::before { content: "참고"; }
.note-warn::before { content: "경고"; background: var(--warning-tint); color: var(--warning-ink); }
.note-err::before  { content: "오류"; background: var(--error-tint);   color: var(--error-ink); }
.note b { color: var(--text); display: block; font-weight: 500; margin-bottom: 2px; }
.note code {
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  padding: 1px 5px;
  border-radius: var(--r-chip);
  background: #F1F1F4;
  color: var(--text);
}

/* ──────────────────────────── tooltip ───────────────────────────────────── */

.tip {
  position: fixed;
  z-index: var(--z-tip);
  max-width: 300px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-panel);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--lift);
  font-size: var(--t-small);
  line-height: 1.65;
  color: var(--text-2);
  pointer-events: none;
}
.tip h4 {
  margin: 0 0 var(--s-1);
  font-family: var(--font-display);
  font-size: var(--t-small);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.tip .tip-good {
  display: block;
  margin-top: var(--s-2); padding-top: var(--s-2);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--t-overline);
  color: var(--success-ink);
}
.tip code { font-family: var(--font-mono); font-size: var(--t-caption); color: var(--text); }

/* ──────────────────────────── responsive ────────────────────────────────── */

/* ── 패널 접기 / 폭 조절 ──────────────────────────────────────────────────
   접어도 폭 값은 그대로 둔다. 다시 펴면 쓰던 폭으로 돌아와야 한다. */
#app[data-left="off"]  { --w-left: 0px; }
#app[data-right="off"] { --w-right: 0px; }
#app[data-left="off"]  #panelLeft,
#app[data-right="off"] #panelRight { overflow: hidden; border: 0; }

.resizer {
  position: absolute;
  top: var(--topbar-h);
  bottom: 0;
  width: var(--resizer);
  z-index: var(--z-sticky);
  cursor: col-resize;
  background: transparent;
  transition: background 120ms ease-out;
}
.resizer::after {           /* 실제로 보이는 1px 선 */
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: calc(var(--resizer) / 2 - 0.5px);
  width: 1px;
  background: transparent;
}
.resizer:hover::after,
.resizer:focus-visible::after,
.resizer.is-dragging::after { background: var(--primary); }
.resizer:focus-visible { outline: none; }

#resizeLeft  { left: calc(var(--w-left) - var(--resizer) / 2); }
#resizeRight { right: calc(var(--w-right) - var(--resizer) / 2); }

/* 접힌 쪽 손잡이는 잡을 게 없다 */
#app[data-left="off"]  #resizeLeft,
#app[data-right="off"] #resizeRight { display: none; }

/* 드래그 중에는 캔버스나 텍스트가 선택되지 않게 */
body.is-resizing { cursor: col-resize; user-select: none; }
body.is-resizing #canvasHost { pointer-events: none; }

.only-narrow { display: none; }

@media (max-width: 1180px) {
  #app { grid-template-columns: 1fr; grid-template-areas: "top" "stage"; }
  .only-narrow { display: inline-flex; }
  .resizer { display: none; }
  /* 좁은 화면에서는 폭을 접는 게 아니라 서랍으로 밀어 넣는다 */
  #app[data-left="off"] #panelLeft,
  #app[data-right="off"] #panelRight { overflow-y: auto; }
  #app[data-left="on"]  #panelLeft  { transform: none; }
  #app[data-right="on"] #panelRight { transform: none; }
  .panel {
    position: fixed;
    top: var(--topbar-h); bottom: 0;
    width: min(320px, 88vw);
    z-index: var(--z-overlay);
    box-shadow: var(--lift);
    transform: translateX(-105%);
    transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  #panelRight { right: 0; transform: translateX(105%); }
  #panelLeft  { left: 0; }
  #panelLeft.is-open, #panelRight.is-open { transform: none; }
  .topbar-stats { display: none; }
  .brand-text { display: none; }
}

@media (max-width: 720px) {
  .tp-field, .tp-frame { display: none; }
  .select-wrap { display: none; }
  .modal { padding: 0; }
  .modal-box { max-height: 100vh; height: 100%; border-radius: 0; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .btn:hover, .tp-btn:hover { transform: none; }
}
