/* Motion Studio - 스튜디오 셸 전용 스타일
 * 토큰은 페이지 <style>의 :root(메인 디자인 토큰) 위에 파생 토큰만 추가한다. */

/* 눈금 토큰 (디자인 트윅 2단계) — 값 하나 = 페이지 전체 일관 반영.
 * 기본값은 기존 하드코딩 값과 동일 (토큰화 자체는 무변화) */
:root {
  --ms-font-xs: 10px;     /* 모노 라벨 (그룹 타이틀, 푸터) */
  --ms-font-md: 12px;     /* 칩/셀렉트/보조 */
  --ms-font-lg: 13px;     /* 컨트롤 본문 (pill, 속성 라벨) */
  --ms-ctl-pad-y: 7px;    /* 버튼(pill) 세로 패딩 */
  --ms-ctl-pad-x: 16px;   /* 버튼(pill) 가로 패딩 */
  --ms-radius-pill: 6px;    /* 버튼 둥글기 (디자인 트윅 확정 — 라이트/다크 공통) */
  --ms-radius-box: 8px;   /* 입력/셀렉트 둥글기 */
  --ms-space-row: 12px;   /* 속성 행 간격 */
  --ms-space-group: 26px; /* 속성 그룹 간격 */
  --ms-panel-pad: 18px;   /* 패널 좌우 패딩 */
  --ms-stage: var(--paper-2); /* 스테이지 배경 (캔버스 주변 우물) */
}
/* 다크: 스테이지는 가장 깊은 층 — 캔버스가 도드라지게. 순흑 직전에서 멈춤 */
[data-theme="dark"] { --ms-stage: #242424; }

.studio {
  --ms-toolbar-h: 48px;
  --ms-panel-w: 320px;
  --ms-rail-w: 56px;
  --ms-drawer-w: 0px;
  --ms-drawer-open-w: 480px;
  --ms-timeline-h: 224px;
  --ms-track-h: 64px;
  --ms-clip-radius: 6px;
  --studio-bg: var(--paper);
  --studio-panel-bg: var(--paper-2);
  --playhead: var(--accent);

  position: relative;
  z-index: 1;
  height: calc(100vh - 80px);
  min-height: 480px;
  display: grid;
  grid-template-rows: var(--ms-toolbar-h) 1fr 6px var(--ms-timeline-h);
  background: var(--studio-bg);
  overflow: hidden;
}
/* 그리드 자식의 min-width:auto가 타임라인 콘텐츠 폭(인라인 width)을 따라
   전체 컬럼을 키우는 것을 차단 — 없으면 창 축소 시 우측 UI가 화면 밖으로 잘림 */
.studio > * { min-width: 0; }

/* ===== 상단 툴바 ===== */
.studio-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--studio-bg);
  min-width: 0;
}
.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
/* 우측 묶음(패널/내보내기)은 어떤 폭에서도 잘리지 않는다 — 좁아지면 좌/중앙이 양보 */
.toolbar-right { flex-shrink: 0; }
.toolbar-left { flex-shrink: 1; overflow: hidden; }
.toolbar-center { flex-shrink: 1; overflow: hidden; }
.toolbar-logo-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}
.toolbar-logo-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--line);
}
.toolbar-time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  min-width: 132px;
  text-align: center;
}
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ghost-btn:hover { background: var(--paper-2); color: var(--ink); }
.ghost-btn:disabled { opacity: .35; cursor: default; }
.ghost-btn:disabled:hover { background: transparent; color: var(--ink-soft); }
.ghost-btn svg { display: block; }
.play-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--studio-bg);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.play-btn:hover { border-color: var(--ink); }
.play-btn.small { width: 26px; height: 26px; }
.save-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  white-space: nowrap;
}

/* pill 버튼 (메인 디자인 규약) */
:is(.studio, .ms-modal-overlay) .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: var(--ms-ctl-pad-y) var(--ms-ctl-pad-x);
  border: 1px solid var(--line);
  border-radius: var(--ms-radius-pill);
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--ms-font-lg);
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
:is(.studio, .ms-modal-overlay) .pill:hover { border-color: var(--ink); }
:is(.studio, .ms-modal-overlay) .pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
:is(.studio, .ms-modal-overlay) .pill.solid {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
:is(.studio, .ms-modal-overlay) .pill.solid:hover { opacity: .88; }
:is(.studio, .ms-modal-overlay) .pill .arrow { font-family: var(--mono); font-size: 12px; }
:is(.studio, .ms-modal-overlay) .pill:disabled { opacity: .4; cursor: default; }

/* ===== 메인 영역: 레일 + 드로어 + 스테이지 + 속성 패널 (캡컷 패턴) ===== */
.studio.drawer-open { --ms-drawer-w: var(--ms-drawer-open-w); }
.studio-main {
  display: grid;
  grid-template-columns: var(--ms-rail-w) var(--ms-drawer-w) 1fr var(--ms-panel-w);
  transition: grid-template-columns .25s ease;
  min-height: 0;
  overflow: hidden;
}
/* 트랙 수 4 불변 — collapsed에서도 동일 (수 불일치 시 보간 사망) */
.studio.panel-collapsed .studio-main {
  grid-template-columns: var(--ms-rail-w) var(--ms-drawer-w) 1fr 0;
}
.studio.panel-collapsed .studio-panel { border-left: none; overflow: hidden; }

/* 아이콘 레일 */
.studio-rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 5px;
  border-right: 1px solid var(--line-soft);
  background: var(--studio-bg);
  overflow-y: auto;
  scrollbar-width: none;
}
.studio-rail::-webkit-scrollbar { display: none; }
.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  padding: 9px 2px;
  border: none;
  background: none;
  border-radius: 9px;
  color: var(--ink-mute);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: -0.01em;
}
.rail-btn:hover { background: var(--paper-2); color: var(--ink); }
.rail-btn.active { background: var(--ink); color: var(--paper); }
.rail-btn svg { display: block; }

/* 드로어 (0px 트랙으로 닫힘 — display:none 금지: transition 사망) */
.studio-drawer {
  overflow: hidden;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--studio-bg);
}
/* 내부 고정폭 — 애니메이션 중 콘텐츠 squish 방지 */
.drawer-inner {
  width: var(--ms-drawer-open-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  flex-shrink: 0;
}
.drawer-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 14px 18px;
}
.drawer-body.library-host {
  display: flex;
  overflow: hidden;
}
/* 넓어진 드로어: 그리드 3열 */
.studio-drawer .library-grid,
.studio-drawer .media-grid {
  grid-template-columns: repeat(3, 1fr);
}

/* ===== 템플릿 탭 ===== */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-top: 4px;
}
.tpl-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--studio-bg);
  transition: border-color .15s, transform .15s;
}
.tpl-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.tpl-thumb-wrap {
  background: #111;
  line-height: 0;
  position: relative;
}
/* 템플릿 코드 배지 (T+4자리) — 검색/마케팅 식별용. 썸네일 좌상단 */
.tpl-code-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(26, 24, 22, 0.72);
  border-radius: 6px;
  padding: 2px 7px;
  line-height: 1.3;
  pointer-events: none;
}
.tpl-thumb {
  width: 100%;
  height: auto;
  display: block;
}
.tpl-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
}
.tpl-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tpl-dur {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
  flex-shrink: 0;
}
.tpl-dev-save {
  margin-top: 16px;
  width: 100%;
  justify-content: center;
}
/* 템플릿 카테고리 필터 */
.tpl-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--studio-bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  margin-bottom: 10px;
}
.tpl-search:focus { border-color: var(--ink); }
.tpl-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.tpl-filter:empty { display: none; }
.tpl-cat-chip {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--studio-bg);
  color: var(--ink-soft);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tpl-cat-chip:hover { border-color: var(--ink); }
.tpl-cat-chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* 내 템플릿 섹션 */
.tpl-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.tpl-section-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.my-tpl-save {
  padding: 5px 12px !important;
  font-size: 12px !important;
}
.my-tpl-empty { padding: 4px 0 8px; }
.tpl-card { position: relative; }
.tpl-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(26, 24, 22, .55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  z-index: 2;
}
.tpl-card:hover .tpl-del { opacity: 1; }
.tpl-del:hover { background: rgba(163, 38, 29, .85); }
/* 저장 모달 입력 */
.my-tpl-name-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
}
.my-tpl-name-input:focus { border-color: var(--accent); }
[data-theme="dark"] .my-tpl-name-input { background: var(--paper); }

/* ===== 인라인 편집 미니 툴바 (선택 굵게) ===== */
.inline-edit-tools {
  position: absolute;
  z-index: 30;
  display: flex;
  gap: 4px;
}
.inline-edit-bold {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 6px 16px -10px rgba(26, 24, 22, .5);
}
.inline-edit-bold:hover { border-color: var(--ink); }
[data-theme="dark"] .inline-edit-bold { background: var(--paper-2); }
.inline-edit-italic {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif-en);
  font-style: italic;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 16px -10px rgba(26, 24, 22, .5);
}
.inline-edit-italic:hover { border-color: var(--ink); }
[data-theme="dark"] .inline-edit-italic { background: var(--paper-2); }
.inline-edit-sep {
  width: 1px;
  height: 18px;
  background: var(--line);
  align-self: center;
  margin: 0 2px;
}
.inline-edit-swatch {
  width: 22px;
  height: 22px;
  align-self: center;
  border: 1.5px solid rgba(255, 255, 255, .75);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 10px -6px rgba(26, 24, 22, .6);
}
.inline-edit-swatch:hover { transform: scale(1.12); }
.inline-edit-font {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif-kr);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 6px 16px -10px rgba(26, 24, 22, .5);
}
.inline-edit-font:hover { border-color: var(--ink); }
[data-theme="dark"] .inline-edit-font { background: var(--paper-2); }
.inline-edit-swatch-custom {
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  position: relative;
  overflow: hidden;
  display: inline-block;
}
.inline-edit-swatch-custom input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ===== 디자인 트윅 모드 (관리자/dev 전용) ===== */
.dt-fab {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 80;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-mute);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px -12px rgba(26, 24, 22, .5);
}
.dt-fab:hover { color: var(--accent); border-color: var(--accent); }
.dt-panel {
  position: fixed;
  left: 14px;
  bottom: 56px;
  z-index: 80;
  width: 250px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 16px 40px -20px rgba(26, 24, 22, .55);
}
.dt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 10px;
}
.dt-head em { font-style: normal; color: var(--accent); margin-left: 6px; }
.dt-close {
  border: none;
  background: transparent;
  color: var(--ink-mute);
  font-size: 15px;
  cursor: pointer;
}
.dt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}
.dt-label { font-size: 11px; color: var(--ink-soft); }

/* 도형 추가 버튼 그리드 (드로어 도형 탭) — 실제 도형 아이콘 + 보조 라벨 */
.shape-add-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
/* 아이콘 그리드 — 라벨 없는 조밀한 그리드 */
.icon-add-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.icon-btn:hover { border-color: var(--ink); background: var(--paper); }
.icon-btn svg { width: 24px; height: 24px; display: block; }
/* 이미지 라이브러리 탭 */
.img-search { margin-bottom: 10px; }
.img-cat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.image-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.image-item {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--paper-2);
  cursor: pointer;
  padding: 0;
}
.image-item:hover { border-color: var(--ink); }
.image-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-item.busy { opacity: .5; pointer-events: none; }
.img-status { font-size: 12px; color: var(--ink-mute); text-align: center; padding: 10px 0; }
.img-status:empty { display: none; padding: 0; }
/* SVG 붙여넣기 모달 */
.svg-paste-input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--studio-bg);
  color: var(--ink);
  resize: vertical;
}
.svg-paste-input:focus { outline: none; border-color: var(--ink); }
.svg-paste-preview { display: flex; justify-content: center; margin-top: 10px; }
.svg-paste-preview canvas { background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px; }
/* 투명 채움 스와치 — 체크무늬로 '비어있음' 표현 */
.swatch-none {
  background-image:
    linear-gradient(45deg, var(--ink-mute) 25%, transparent 25%),
    linear-gradient(-45deg, var(--ink-mute) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--ink-mute) 75%),
    linear-gradient(-45deg, transparent 75%, var(--ink-mute) 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  background-color: var(--paper);
}
.shape-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--ms-radius-box);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .15s, color .15s, transform .15s;
}
.shape-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.shape-btn svg { width: 30px; height: 30px; }
.shape-btn span { font-size: 10px; color: var(--ink-mute); }
.shape-btn:hover span { color: var(--ink-soft); }
/* 시작 화면 (A0) — 빈 캔버스 공포 제거: 진입 카드 3종 */
.start-title {
  font-family: var(--serif-kr), var(--serif-en), serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 22px;
}
.start-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 190px));
  gap: 14px;
  margin-bottom: 18px;
}
.start-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 14px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.start-card:hover {
  border-color: var(--accent);
  color: var(--ink);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -18px rgba(26, 24, 22, .45);
}
.start-card svg { color: var(--accent); }
.start-card-title {
  font-size: var(--ms-font-lg);
  font-weight: 700;
  color: var(--ink);
}
.start-card-desc {
  font-size: 11px;
  color: var(--ink-mute);
  line-height: 1.4;
}
@media (max-width: 768px) {
  .start-cards { grid-template-columns: 1fr; gap: 10px; }
  .start-card { flex-direction: row; justify-content: flex-start; padding: 14px 16px; }
  .start-card-desc { margin-left: auto; }
}

/* AI 초안 패널 (A2) — 사진 끼운 시안 3장 */
.draft-status {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin-bottom: 16px;
}
.draft-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.draft-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.draft-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -18px rgba(26, 24, 22, .45);
}
.draft-card-canvas {
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #000;
  display: block;
}
.draft-card-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}
@media (max-width: 600px) {
  .draft-cards { grid-template-columns: 1fr; }
}

/* 단색 배경 스와치 행 */
.solid-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
/* 단색 클립: 필름스트립 대신 색 자체가 칩 (밝은 색에서도 라벨이 보이게 윤곽) */
.clip.clip-solid .clip-label {
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.55);
  color: #fff;
}
/* 타임라인 도형 클립: 텍스트 클립과 동일하게 필름스트립 없는 단색 칩 */
.clip.clip-shape { background: var(--accent-soft); }
.dt-section {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 10px 0 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.dt-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.dt-slider {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dt-slider input[type="range"] { width: 90px; }
.dt-val {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
  min-width: 24px;
  text-align: right;
}
.dt-panel { max-height: 76vh; overflow-y: auto; }
.dt-row input[type="color"] {
  width: 34px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}
.dt-text {
  width: 120px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10px;
}
.dt-foot {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}
.dt-foot .pill { padding: 4px 12px; font-size: 12px; }
.dt-export {
  width: 100%;
  min-height: 140px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  resize: vertical;
}
[data-theme="dark"] .dt-panel, [data-theme="dark"] .dt-fab { background: var(--paper-2); }

/* ===== 지속 공지 배너 (환경 제약 등 — 닫기 전까지 유지) ===== */
.ms-notice {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(560px, calc(100% - 48px));
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 10px 28px -16px rgba(26, 24, 22, .4);
}
.ms-notice-text {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.ms-notice-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-mute);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.ms-notice-close:hover { background: var(--paper-2); color: var(--ink); }
[data-theme="dark"] .ms-notice { background: var(--paper-2); }

/* ===== 멀티 사이즈 내보내기 ===== */
.export-size-note {
  font-size: 11px;
  color: var(--ink-mute);
  line-height: 1.6;
  margin: -2px 0 4px;
}
.export-size-status {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
  min-height: 14px;
}
.export-done-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 4px;
}
.export-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.export-file-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
}
.export-file-row .pill {
  padding: 4px 12px;
  font-size: 12px;
}

/* 속성 패널 헤더 (탭 제거 후) */
.panel-head {
  padding: 12px 18px 9px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}

.studio-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ms-stage);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  padding: 28px;
}
/* 팝오버/모달은 기본면보다 한 단계 밝게 (다크모드 elevation) */
[data-theme="dark"] .ms-modal,
[data-theme="dark"] .font-picker,
[data-theme="dark"] .ms-context-menu {
  background: var(--paper-2);
}

.stage-canvas-wrap {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 24px 60px -36px rgba(26, 24, 22, .4);
}
.stage-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #000;
}
.stage-hud {
  position: absolute;
  left: 14px;
  bottom: 10px;
  display: flex;
  gap: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  pointer-events: none;
}

/* 빈 상태 (클립 0개) - 스테이지 전체 드롭존 */
.stage-empty {
  position: absolute;
  inset: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  cursor: pointer;
  text-align: center;
  padding: 24px;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 48px 48px;
  transition: border-color .2s, background-color .2s;
}
.stage-empty:hover, .stage-empty.dragover { border-color: var(--accent); }
.stage-empty.dragover { background-color: rgba(183, 92, 42, 0.04); }
.stage-empty .upload-icon { color: var(--ink-mute); margin-bottom: 10px; }
.stage-empty .upload-title {
  font-family: var(--serif-kr);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}
.stage-empty .upload-subtitle {
  font-size: 14px;
  color: var(--ink-soft);
}
.stage-empty .upload-formats {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 6px;
}
.stage-empty .pill { margin-top: 18px; }

/* 스테이지 위 드래그오버 (클립 존재 시 추가 업로드) */
.studio-stage.dragover::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  pointer-events: none;
}

/* ===== 우측 패널 ===== */
.studio-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--studio-bg);
  transition: width .2s;
}
.panel-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-tabs .pill { padding: 5px 14px; font-size: 12px; }
.panel-collapse-btn { margin-left: auto; }
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px var(--ms-panel-pad) 24px;
  min-height: 0;
}
.panel-footer {
  padding: 10px var(--ms-panel-pad);
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: var(--ms-font-xs);
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  display: flex;
  justify-content: space-between;
}

/* 그룹 = 흰 라운드 카드 (크림 패널 위에 떠 보이게 — 명확한 구분) */
.prop-group {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
[data-theme="dark"] .prop-group { background: #3f3f3f; }
.prop-group-title {
  font-family: var(--mono);
  font-size: var(--ms-font-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: var(--ms-space-row);
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* 카드 가장자리가 구분하므로 제목 옆 긴 선 제거 */
/* 접기/펼치기 — 제목 클릭 토글 (가독성: 긴 패널 정돈) */
.prop-group-title.collapsible {
  cursor: pointer;
  user-select: none;
  border-radius: 5px;
}
.prop-group-title.collapsible:hover { color: var(--ink); }
.prop-group-title.collapsible::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: translateY(-1px) rotate(45deg);
  transition: transform .15s ease;
}
.prop-group.collapsed > .prop-group-title.collapsible::before { transform: translateY(1px) rotate(-45deg); }
.prop-group.collapsed > :not(.prop-group-title) { display: none; }
.prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: var(--ms-space-row);
}
.prop-label { font-size: var(--ms-font-lg); color: var(--ink-soft); flex-shrink: 0; }
.prop-pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.prop-pills .pill { padding: 4px 12px; font-size: 12px; }

.num-input {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--studio-bg);
}
.num-input input {
  width: 56px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  padding: 6px 2px;
  outline: none;
  -moz-appearance: textfield;
}
.num-input input::-webkit-outer-spin-button,
.num-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input button {
  width: 24px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
}
.num-input button:hover { background: var(--paper-2); color: var(--ink); }
.num-unit { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); padding-right: 8px; }

.range-row { display: flex; align-items: center; gap: 10px; flex: 1; }
/* 스냅 정렬 가이드선 (드래그 중 자석 정렬 표시) */
.snap-guide-v, .snap-guide-h { position: absolute; display: none; background: var(--accent); pointer-events: none; z-index: 5; }
.snap-guide-v { top: 0; bottom: 0; width: 1px; }
.snap-guide-h { left: 0; right: 0; height: 1px; }

/* 정밀 배치 수치 입력 (위치 X/Y, 크기 W/H) */
.num-pair { display: flex; gap: 10px; }
.num-pair label { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-mute); }
.num-pair input[type="number"] { width: 52px; padding: 5px 7px; border: 1px solid var(--line); border-radius: var(--ms-radius-box); font-size: 12px; background: var(--paper); color: var(--ink); }
:is(.studio, .ms-modal-overlay) input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
  min-width: 60px;
}
:is(.studio, .ms-modal-overlay) input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: none;
}
:is(.studio, .ms-modal-overlay) input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: none;
}
.range-value { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); min-width: 38px; text-align: right; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-family: var(--sans);
}
.link-btn:hover { color: var(--accent); border-color: var(--accent); }

.color-swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
}
.color-swatch.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.color-swatch input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }
/* 스포이드 — 색 추출. 최근 색과 구분되게 면 대신 아이콘 */
.color-eyedrop {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  color: var(--ink);
}
.color-eyedrop:hover { border-color: var(--ink); }
.color-eyedrop svg { display: block; }
/* 최근 색 — 구분용 가느다란 구분선 앞에 배치된 작은 스와치 */
/* 최근색도 다른 색칩과 동일 크기 — 줄 맞춤(격자 정렬) 유지 */

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  padding: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink-mute);
  transition: transform .15s, background .15s;
}
.toggle.on { background: var(--ink); border-color: var(--ink); }
.toggle.on::after { transform: translateX(16px); background: var(--paper); }

/* 미디어 빈 */
.media-drop {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-mute);
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color .15s;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 24px 24px;
}
.media-drop:hover, .media-drop.dragover { border-color: var(--accent); color: var(--ink-soft); }
.media-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.media-item {
  position: relative;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper-2);
}
.media-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.media-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}
.media-item-add {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
}
.media-item-add:hover { color: var(--accent); }
.media-use-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(26, 24, 22, .7);
  color: #f0ece4;
  font-family: var(--mono);
  font-size: 10px;
  border-radius: 4px;
  padding: 1px 5px;
}

.panel-empty-note {
  font-size: 12px;
  color: var(--ink-mute);
  line-height: 1.7;
  padding: 8px 0;
}

/* ===== 타임라인 리사이저 ===== */
.timeline-resizer {
  cursor: row-resize;
  background: var(--studio-bg);
  border-top: 1px solid var(--line);
  position: relative;
}
.timeline-resizer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  transform: translateX(-50%);
  width: 36px;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
}
.timeline-resizer:hover::after { background: var(--ink-mute); }

/* ===== 타임라인 ===== */
.studio-timeline {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--studio-bg);
  user-select: none;
  -webkit-user-select: none;
}
.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.timeline-toolbar .spacer { flex: 1; }
.timeline-zoom {
  display: flex;
  align-items: center;
  gap: 8px;
}
.timeline-zoom .zoom-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
}
.timeline-zoom input[type="range"] { width: 90px; }

.timeline-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  min-height: 0;
}
.timeline-content {
  position: relative;
  min-height: 100%;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  /* 시작점 앞 여백 (FCP식) — 투명 보더라 절대배치 자식(클립/플레이헤드/가이드)이
     전부 함께 밀린다. 입력 좌표는 timeline-ui.js의 toContentX에서 TL_PAD로 보정 */
  border-left: 24px solid transparent;
}
.timeline-ruler {
  display: block;
  height: 24px;
  cursor: ew-resize;
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--studio-bg);
  flex-shrink: 0;
}
/* 트랙 행 스택: main이 바닥, 오버레이가 위로 자람 (FCP) */
.tl-rows {
  --ms-overlay-h: 40px;
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 0 10px;
  min-height: calc(100% - 24px);
}
.timeline-track {
  position: relative;
  border-radius: var(--ms-clip-radius);
  flex-shrink: 0;
}
.timeline-track.main { height: var(--ms-track-h); }
.timeline-track.overlay {
  height: var(--ms-overlay-h);
  background: var(--line-soft);
}
/* 잠긴 클립: 보이되 손대지 못함 (우클릭 해제만).
   사선 빗금 = 영상 에디터의 잠금 관례 (프리미어/FCP) */
.clip.locked {
  opacity: 0.7;
  cursor: default;
}
.clip.locked .clip-trim { display: none; }
.clip.locked::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(
    -45deg,
    rgba(26, 24, 22, 0.22) 0 5px,
    transparent 5px 11px
  );
  pointer-events: none;
  z-index: 2;
}
.clip-lock {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: rgba(26, 24, 22, 0.78);
  color: #f6f3ee;
  z-index: 3;
  pointer-events: none;
}
.clip-lock svg { display: block; }

/* 가시성 토글 (눈) — 좌상단. 평소 숨김, 호버/선택/숨김상태에서 노출 */
.clip-eye {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 5px;
  background: rgba(26, 24, 22, 0.78);
  color: #f6f3ee;
  z-index: 4;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity .12s, background .12s;
}
.clip:hover .clip-eye,
.clip.selected .clip-eye,
.clip.clip-hidden .clip-eye { opacity: 1; }
.clip-eye:hover { background: var(--accent); }
.clip-eye svg { display: block; }
/* 숨김 상태 — 흐리게 (잠금 빗금과 구분) */
.clip.clip-hidden { opacity: 0.42; }
.clip.clip-hidden .clip-label { font-style: italic; }
/* 그룹 — 상단 색 띠 (같은 groupId = 같은 색) */
.clip.clip-grouped::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: hsl(var(--group-hue, 0), 70%, 56%);
  z-index: 3;
  pointer-events: none;
  border-radius: var(--ms-clip-radius) var(--ms-clip-radius) 0 0;
}

.timeline-track.drop-target {
  outline: 1.5px dashed var(--accent);
  outline-offset: 1px;
}
.tl-new-track-zone {
  height: 20px;
  flex-shrink: 0;
  border: 1px dashed var(--line);
  border-radius: 6px;
  margin-bottom: 2px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tl-new-track-zone.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(183, 92, 42, .06);
}
/* 행 경계 삽입선 — 드래그 중 갭 호버 시 새 층이 생길 위치 표시 */
.tl-insert-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  margin-top: -1px;
  background: var(--accent);
  border-radius: 1px;
  pointer-events: none;
  z-index: 6;
  box-shadow: 0 0 6px rgba(183, 92, 42, .45);
}
/* main 총길이 경계선 (오버레이 존재 시) */
.timeline-end-line {
  position: absolute;
  top: 24px;
  bottom: 0;
  width: 0;
  border-left: 1px dashed var(--ink-mute);
  opacity: .4;
  pointer-events: none;
  z-index: 5;
}

/* 클립 블록 */
.clip {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: var(--ms-clip-radius);
  overflow: hidden;
  cursor: grab;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  background-color: var(--paper-2);
  background-size: auto 100%;
  background-repeat: repeat-x;
  transition: left .15s ease, width .08s ease;
}
.clip.no-anim { transition: none; }
.clip.dragging {
  z-index: 30;
  cursor: grabbing;
  transition: none;
  opacity: .9;
  box-shadow: 0 10px 24px -10px rgba(26, 24, 22, .5);
}
.clip.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--accent);
}
.clip-label {
  position: absolute;
  left: 6px;
  bottom: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #f0ece4;
  background: rgba(26, 24, 22, .65);
  border-radius: 4px;
  padding: 1px 5px;
  pointer-events: none;
  white-space: nowrap;
}
.clip.selected .clip-label { background: var(--accent); }
.clip-trim {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  opacity: 0;
  transition: opacity .12s;
  z-index: 2;
}
.clip-trim::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 2px;
  background: rgba(240, 236, 228, .9);
  box-shadow: 0 0 0 1px rgba(26, 24, 22, .35);
}
.clip-trim.left { left: 0; }
.clip-trim.left::after { left: 3px; }
.clip-trim.right { right: 0; }
.clip-trim.right::after { right: 3px; }
.clip:hover .clip-trim, .clip.selected .clip-trim { opacity: 1; }

.trim-tooltip {
  position: absolute;
  transform: translate(-50%, -130%);
  font-family: var(--mono);
  font-size: 10px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 5px;
  padding: 2px 7px;
  pointer-events: none;
  z-index: 40;
  white-space: nowrap;
}

/* 전환 노드 (클립 경계 배지) */
.transition-node {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px dashed var(--ink-mute);
  background: var(--studio-bg);
  color: var(--ink-mute);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  padding: 0;
  transition: border-color .15s, background .15s;
}
.transition-node:hover { border-color: var(--accent); color: var(--accent); }
.transition-node.has-transition {
  border: none;
  background: var(--accent);
  color: #fff;
}
.transition-node svg { display: block; }

/* 플레이헤드 */
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  z-index: 20;
  pointer-events: none;
}
.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -0.75px;
  width: 1.5px;
  background: var(--playhead);
}
.playhead-cap {
  position: absolute;
  top: 0;
  left: -5px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--playhead);
}

/* 스테이지 기즈모 (오버레이 클립 캔버스 직접 조작) */
.stage-gizmo {
  position: absolute;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .35);
  cursor: move;
  z-index: 10;
  display: none;
}
.stage-gizmo.visible { display: block; }
.gizmo-handle {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--accent);
  box-shadow: 0 1px 3px rgba(26, 24, 22, .35);
}
/* 다중 선택 외곽선 (핸들 없음 — 묶음 드래그/정렬 대상 표시) */
.gizmo-multi {
  position: absolute;
  border: 1.5px dashed var(--accent);
  border-radius: 2px;
  pointer-events: none;
  z-index: 9;
}
/* 정렬 버튼 (아이콘 pill) */
.align-btn {
  padding: 6px 9px !important;
}
.align-btn svg { display: block; }

.gizmo-rotate {
  position: absolute;
  top: -32px;
  left: 50%;
  margin-left: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--accent);
  cursor: grab;
  box-shadow: 0 2px 8px -3px rgba(26, 24, 22, .5);
}
.gizmo-rotate::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1.5px;
  height: 18px;
  background: var(--accent);
  margin-left: -0.75px;
}
.gizmo-rotate:active { cursor: grabbing; }
.gizmo-handle[data-corner="nw"] { left: -6px; top: -6px; cursor: nwse-resize; }
.gizmo-handle[data-corner="ne"] { right: -6px; top: -6px; cursor: nesw-resize; }
.gizmo-handle[data-corner="sw"] { left: -6px; bottom: -6px; cursor: nesw-resize; }
.gizmo-handle[data-corner="se"] { right: -6px; bottom: -6px; cursor: nwse-resize; }

/* 스냅 가이드라인 */
.tl-snap-guide {
  position: absolute;
  top: 24px;
  bottom: 0;
  width: 0;
  border-left: 1px solid var(--accent);
  pointer-events: none;
  z-index: 18;
}

/* 클립 필름스트립 캔버스 */
.clip-film {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.clip-label { z-index: 1; }
.clip-trim { z-index: 2; }

/* 컨텍스트 메뉴 */
.ms-context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 180px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 50px -20px rgba(26, 24, 22, .45);
  padding: 5px;
}
.ms-context-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.ms-context-item:hover { background: var(--paper-2); }
.ms-context-item:disabled { opacity: .35; cursor: default; }
.ms-context-item:disabled:hover { background: none; }
.ms-context-item.danger { color: var(--accent); }
.ms-context-kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
}
.ms-context-separator {
  height: 1px;
  background: var(--line-soft);
  margin: 4px 6px;
}

/* 텍스트 클립 */
.text-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--ms-radius-box);
  background: var(--studio-bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--ms-font-lg);
  line-height: 1.5;
  padding: 8px 10px;
  resize: vertical;
  outline: none;
}
.text-input:focus { border-color: var(--ink); }
.anim-select {
  border: 1px solid var(--line);
  border-radius: var(--ms-radius-box);
  background: var(--studio-bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--ms-font-md);
  padding: 5px 8px;
  max-width: 170px;
}
.clip.clip-text {
  background: var(--accent-soft);
  background-image: none !important;
}
.clip.clip-text .clip-label {
  background: rgba(183, 92, 42, .85);
}

/* GIF 소스 라이브러리 패널: 좌측 세로 카테고리 레일 + 우측 콘텐츠 */
.panel-body.library-mode {
  display: flex;
  overflow: hidden;
  padding-right: 10px;
}
.library-panel {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
}
.library-rail {
  overflow-y: auto;
  min-height: 0;
  border-right: 1px solid var(--line-soft);
  padding-right: 6px;
  scrollbar-width: none;
}
.library-rail::-webkit-scrollbar { display: none; }
.library-rail-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink-soft);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  word-break: keep-all;
}
.library-rail-btn:hover { background: var(--paper-2); }
.library-rail-btn.active {
  background: var(--ink);
  color: var(--paper);
}
.library-rail-btn.special { color: var(--ink-mute); }
.library-rail-btn.special.active { color: var(--paper); }
.library-rail-divider {
  height: 1px;
  background: var(--line-soft);
  margin: 6px 4px;
}
/* 아코디언 소분류 */
.library-rail-subs {
  display: none;
  padding: 2px 0 4px 8px;
}
.library-rail-group.open .library-rail-subs { display: block; }
.library-sub-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-mute);
  padding: 4px 7px;
  border-radius: 5px;
  cursor: pointer;
  word-break: keep-all;
}
.library-sub-btn:hover { background: var(--paper-2); color: var(--ink); }
.library-sub-btn.active {
  color: var(--accent);
  background: rgba(183, 92, 42, .08);
  font-weight: 600;
}
.library-main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}
.library-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--studio-bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
}
.library-search:focus { border-color: var(--ink); }
.library-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
/* 카테고리 칩 1줄 가로 스크롤 (수직 공간 절약 — 캡컷 패턴) */
.library-chips-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.library-chips-scroll::-webkit-scrollbar { display: none; }
.library-chips-scroll .library-chip { flex-shrink: 0; }
.library-chip.special { border-style: dashed; }
.library-chip-divider {
  flex-shrink: 0;
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin: 2px 3px;
}
.library-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
}
.library-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.library-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.library-item {
  position: relative;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper-2);
  cursor: pointer;
}
.library-item:hover { border-color: var(--accent); }
.library-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: opacity .18s ease;
}
.library-item.loading { opacity: .5; pointer-events: none; }

/* 즐겨찾기 별표 */
.library-fav {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: rgba(26, 24, 22, .45);
  color: rgba(255, 255, 255, .85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  fill: none;
}
.library-item:hover .library-fav { opacity: 1; }
.library-fav.active {
  opacity: 1;
  background: var(--accent);
  color: #fff;
}
.library-fav.active svg { fill: currentColor; }

/* 추가됨 피드백 */
.library-added {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(183, 92, 42, .55);
  color: #fff;
  pointer-events: none;
}
.library-item.added .library-added { display: flex; }

/* 스켈레톤 로딩 */
.library-item.skeleton { pointer-events: none; border-color: transparent; }
.library-skel-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(100deg, var(--paper-2) 40%, var(--line-soft) 50%, var(--paper-2) 60%);
  background-size: 200% 100%;
  animation: ms-shimmer 1.2s linear infinite;
}
.library-skel-line {
  height: 9px;
  margin: 5px 6px;
  border-radius: 4px;
  background: var(--paper-2);
}
@keyframes ms-shimmer {
  to { background-position: -200% 0; }
}

/* 검색 0건 제안 */
.library-status-line { margin-bottom: 8px; }
.library-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  align-items: center;
}
.library-suggest-label {
  width: 100%;
  font-size: 11px;
  color: var(--ink-mute);
  margin-bottom: 4px;
}
.library-name {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-premium {
  position: absolute;
  top: 5px;
  right: 5px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  border-radius: 4px;
  padding: 1px 5px;
}
.library-status {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
  text-align: center;
  padding: 6px 0;
}
.library-sentinel { height: 1px; }

/* 인라인 텍스트 편집 (캔버스 더블클릭) */
.inline-text-editor {
  position: absolute;
  z-index: 12;
  background: rgba(26, 24, 22, .25);
  border: 1.5px dashed var(--accent);
  border-radius: 6px;
  outline: none;
  resize: none;
  overflow: hidden;
  padding: 8px 16px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  /* contenteditable: 내용 폭을 따라 자라고(fitEditor가 중심 재배치) 개행 보존 */
  width: max-content;
  min-width: 120px;
  max-width: 92vw;
  white-space: pre-wrap;
  caret-color: var(--accent);
}

/* 폰트 피커 */
.font-current {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--studio-bg);
  color: var(--ink);
  font-size: 14px;
  padding: 6px 12px;
  cursor: pointer;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-current:hover { border-color: var(--ink); }
.font-picker {
  position: fixed;
  z-index: 1200;
  width: 290px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 60px -24px rgba(26, 24, 22, .5);
  padding: 10px;
}
.font-picker-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--studio-bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  margin-bottom: 8px;
}
.font-picker-search:focus { border-color: var(--ink); }
.font-picker-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.font-picker-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
}
.font-picker-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.font-picker-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.font-picker-item {
  border: none;
  background: none;
  text-align: left;
  font-size: 16px;
  color: var(--ink);
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* flex column + max-height 컨테이너에서 overflow:hidden 항목은 min-height가 0이 되어
     스크롤 대신 압축됨 — 글자 윗부분만 보이던 버그의 원인 */
  flex-shrink: 0;
}
.font-picker-item:hover { background: var(--paper-2); }
.font-picker-item.active { background: var(--accent-soft); }

/* 전환 타입 그리드 (속성 패널) */
.tr-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.tr-type-grid .pill {
  justify-content: center;
  padding: 6px 8px;
  font-size: 12px;
}

/* 러버밴드 */
.rubber-band {
  position: absolute;
  border: 1px solid var(--accent);
  background: rgba(183, 92, 42, .08);
  z-index: 25;
  pointer-events: none;
}

/* ===== 모달 공통 ===== */
.ms-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 24, 22, .55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ms-modal {
  width: 460px;
  max-width: 100%;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .5);
  padding: 24px 26px;
}
.ms-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.ms-modal-title {
  font-family: var(--serif-kr);
  font-size: 21px;
  font-weight: 500;
  color: var(--ink);
}
.ms-modal-close {
  border: none;
  background: none;
  color: var(--ink-mute);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ms-modal-close:hover { background: var(--paper-2); color: var(--ink); }
.ms-modal-foot {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  display: flex;
  justify-content: space-between;
}

/* 내보내기 모달 */
.format-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.export-options .prop-row { margin-bottom: 14px; }
.export-estimate {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  margin: 14px 0 18px;
}
.export-start-row { display: flex; justify-content: flex-end; }
.export-alert {
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: rgba(183, 92, 42, .07);
  color: var(--accent);
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.export-alert a, .export-alert button {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

.export-steps { list-style: none; margin: 6px 0 16px; padding: 0; }
.export-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-mute);
  padding: 5px 0;
}
.export-steps li .step-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
}
.export-steps li.active { color: var(--ink); }
.export-steps li.active .step-dot { background: var(--accent); }
.export-steps li.done { color: var(--ink-soft); }
.export-steps li.done .step-dot { background: var(--ink-soft); }
.progress-bar {
  height: 2px;
  background: var(--line-soft);
  border-radius: 2px;
  overflow: hidden;
  margin: 10px 0 8px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .2s ease;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-mute);
}
.export-done-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
  max-height: 260px;
}
.export-done-preview img, .export-done-preview video {
  max-width: 100%;
  max-height: 260px;
  display: block;
}
.export-done-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.export-done-size { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }
.export-reexport-note { font-size: 11px; color: var(--ink-mute); margin-top: 10px; }

/* 단축키 도움말 */
.shortcut-table { width: 100%; border-collapse: collapse; }
.shortcut-table td { padding: 6px 4px; font-size: 13px; color: var(--ink-soft); }
.shortcut-table td:first-child { width: 45%; }
.shortcut-table kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  margin-right: 3px;
  color: var(--ink);
}

/* 토스트 */
.ms-toast {
  position: fixed;
  left: 50%;
  top: 130px; /* navbar(74) + studio-toolbar(48) 아래 = 스테이지 상단. 지속 공지(.ms-notice)와 같은 상단 정렬 */
  transform: translate(-50%, -16px);
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  border-radius: 999px;
  padding: 9px 20px;
  z-index: 1100;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  font-family: var(--sans);
}
.ms-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 코치마크 */
.coachmark {
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translate(-50%, -100%);
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  line-height: 1.5;
  border-radius: 8px;
  padding: 8px 14px;
  z-index: 50;
  white-space: nowrap;
}
.coachmark::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--ink);
}

/* 모바일 안내 */
.mobile-notice {
  display: none;
  padding: 10px 16px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 1366px) {
  .studio { --ms-drawer-open-w: 400px; }
}
@media (max-width: 1180px) {
  .studio { --ms-panel-w: 280px; }
}
@media (max-width: 1100px) {
  .studio { --ms-drawer-open-w: 360px; }
  .studio-drawer .library-grid,
  .studio-drawer .media-grid { grid-template-columns: repeat(2, 1fr); }
}
/* 툴바 단계적 축소: 저장 배지/단축키 -> 시간 표시 -> 로고 텍스트 순으로 양보 */
@media (max-width: 1020px) {
  .save-badge { display: none; }
  #shortcutHelpBtn { display: none; }
}
@media (max-width: 860px) {
  .toolbar-time { display: none; }
  .toolbar-center .toolbar-divider { display: none; }
}
@media (max-width: 600px) {
  .toolbar-logo-chip .pa-tool-header-title { display: none; }
  :is(.studio, .ms-modal-overlay) .pill.solid { padding: 7px 12px; }
}
@media (max-width: 768px) {
  .mobile-notice { display: block; }
  .studio {
    --ms-rail-w: 48px;
    height: auto;
    min-height: 0;
    grid-template-rows: var(--ms-toolbar-h) minmax(260px, 46vh) 6px 200px;
  }
  .studio-main { grid-template-columns: var(--ms-rail-w) 0 1fr 0; }
  /* 드로어 = 바텀시트 (fixed라 0 트랙과 무관) */
  .studio.drawer-open .studio-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 56vh;
    z-index: 900;
    border-top: 1px solid var(--line);
    border-right: none;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -20px 50px -20px rgba(26, 24, 22, .4);
  }
  .studio.drawer-open .studio-drawer::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 3px;
    border-radius: 3px;
    background: var(--line);
    z-index: 1;
  }
  .studio.drawer-open .drawer-inner { width: 100%; padding-top: 8px; }
  .studio-panel {
    display: none;
  }
  .studio.mobile-panel-open .studio-panel {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 56vh;
    z-index: 900;
    border-top: 1px solid var(--line);
    border-left: none;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -20px 50px -20px rgba(26, 24, 22, .4);
  }
  /* 바텀시트 그랩 핸들 */
  .studio.mobile-panel-open .studio-panel::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 3px;
    border-radius: 3px;
    background: var(--line);
  }
  .studio.mobile-panel-open .panel-body { padding-top: 16px; }
  .toolbar-time { min-width: 0; font-size: 11px; }
  .clip-trim { display: none; }
}
