/* ============================================================
   Design Studio — 디자인 시스템 생성기 (독립형 다크 UI)
   앱 자체 토큰: --dsg-*  /  미리보기 캔버스 토큰: --p-*
   ============================================================ */

:root {
  --dsg-bg: #0e1217;
  --dsg-surface: #151b23;
  --dsg-surface-2: #1a2230;
  --dsg-surface-3: #212b3b;
  --dsg-border: #2a3444;
  --dsg-border-soft: #222b39;
  --dsg-text: #e8edf4;
  --dsg-sub: #97a3b4;
  --dsg-faint: #5d6a7d;
  --dsg-accent: #4c8dff;
  --dsg-accent-hover: #6599ff;
  --dsg-accent-soft: rgba(76, 141, 255, .13);
  --dsg-ok: #3fb950;
  --dsg-ok-soft: rgba(63, 185, 80, .13);
  --dsg-warn: #d29922;
  --dsg-warn-soft: rgba(210, 153, 34, .13);
  --dsg-danger: #f85149;
  --dsg-danger-soft: rgba(248, 81, 73, .12);

  --dsg-radius: 12px;
  --dsg-radius-sm: 8px;
  --dsg-radius-xs: 6px;
  --dsg-header-h: 56px;
  --dsg-side-w: 380px;
  --dsg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --dsg-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--dsg-bg);
  color: var(--dsg-text);
  font-family: var(--dsg-font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- 앱 레이아웃 ---------- */

#app { display: flex; flex-direction: column; height: 100vh; }

#app-header {
  display: flex; align-items: center; gap: 16px;
  height: var(--dsg-header-h); padding: 0 16px;
  background: var(--dsg-surface);
  border-bottom: 1px solid var(--dsg-border-soft);
  flex: none;
}

.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px;
  background: conic-gradient(from 220deg, #4c8dff, #8b7bff, #4cd9ff, #4c8dff);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.brand-name { font-weight: 700; letter-spacing: -.01em; }
.brand-sub { color: var(--dsg-faint); font-size: 12px; padding-top: 1px; }

.url-form { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
#url-input {
  flex: 1; min-width: 120px; height: 34px; padding: 0 12px;
  background: var(--dsg-bg); border: 1px solid var(--dsg-border);
  border-radius: var(--dsg-radius-sm); color: var(--dsg-text);
  font-size: 13px; transition: border-color .15s;
}
#url-input::placeholder { color: var(--dsg-faint); }
#url-input:focus { outline: none; border-color: var(--dsg-accent); }

.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.v-divider { width: 1px; height: 20px; background: var(--dsg-border-soft); margin: 0 4px; }

.source-badge {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--dsg-sub);
  background: var(--dsg-surface-2); border: 1px solid var(--dsg-border-soft);
  border-radius: 999px; padding: 3px 10px;
}

/* ---------- 버튼 ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--dsg-radius-sm);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--dsg-accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--dsg-accent-hover); }

.btn-accent {
  background: var(--dsg-accent-soft); color: var(--dsg-accent);
  border-color: rgba(76, 141, 255, .35);
}
.btn-accent:hover:not(:disabled) { background: rgba(76, 141, 255, .2); }

.btn-ghost { color: var(--dsg-sub); border-color: var(--dsg-border); }
.btn-ghost:hover:not(:disabled) { color: var(--dsg-text); border-color: var(--dsg-faint); }

.btn-danger { color: var(--dsg-danger); border-color: rgba(248, 81, 73, .4); }
.btn-danger:hover:not(:disabled) { background: var(--dsg-danger-soft); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: var(--dsg-radius-xs); }
.btn-block { width: 100%; }

/* ---------- 메인 3분할 ---------- */

#app-main { display: flex; flex: 1; min-height: 0; }

/* ---------- 좌측 패널 ---------- */

#side-panel {
  width: var(--dsg-side-w); flex: none;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--dsg-surface);
  border-right: 1px solid var(--dsg-border-soft);
}

#side-nav {
  display: flex; gap: 4px; padding: 10px 12px 6px;
  border-bottom: 1px solid var(--dsg-border-soft);
  overflow-x: auto; scrollbar-width: none; flex: none;
}
#side-nav::-webkit-scrollbar { display: none; }

.nav-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--dsg-sub);
  border: 1px solid transparent; white-space: nowrap;
}
.nav-chip:hover { color: var(--dsg-text); }
.nav-chip.is-active {
  color: var(--dsg-accent); background: var(--dsg-accent-soft);
  border-color: rgba(76, 141, 255, .35);
}

.adjust-pane { flex: 1; overflow-y: auto; padding: 14px 16px 40px; }

.adj-empty { color: var(--dsg-faint); font-size: 13px; padding: 8px 2px; }

.adj-block { margin-bottom: 20px; }
.adj-block-title {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  color: var(--dsg-faint); text-transform: uppercase;
  margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between;
}
.adj-block-title .btn-sm { color: var(--dsg-sub); }

.adj-row {
  display: grid; grid-template-columns: 24px 1fr auto; align-items: center;
  gap: 8px; padding: 7px 8px; border-radius: var(--dsg-radius-sm);
  border: 1px solid var(--dsg-border-soft); background: var(--dsg-surface-2);
  margin-bottom: 6px;
}
.adj-row .swatch {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  border: 1px solid rgba(255,255,255,.14); cursor: pointer; padding: 0;
  background: none; position: relative; overflow: hidden;
}
.adj-row .swatch input[type="color"] {
  position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px);
  border: none; padding: 0; cursor: pointer;
}
.adj-row .adj-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.adj-row input[type="text"] {
  background: transparent; border: none; color: var(--dsg-text);
  font-size: 13px; font-weight: 600; padding: 0; width: 100%;
}
.adj-row input[type="text"]:focus { outline: none; }
.adj-row .adj-sub {
  font-family: var(--dsg-mono); font-size: 11px; color: var(--dsg-faint);
  border: none; background: transparent; padding: 0; width: 100%;
}
.adj-row .adj-sub:focus { color: var(--dsg-sub); outline: none; }
.adj-row .row-actions { display: flex; gap: 2px; }
.icon-btn {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--dsg-faint); font-size: 13px; line-height: 1;
}
.icon-btn:hover { color: var(--dsg-text); background: var(--dsg-surface-3); }
.icon-btn.danger:hover { color: var(--dsg-danger); }

.adj-field { margin-bottom: 10px; }
.adj-field label {
  display: block; font-size: 12px; color: var(--dsg-sub); margin-bottom: 4px; font-weight: 600;
}
.adj-field input[type="text"], .adj-field input[type="url"], .adj-field select, .adj-field textarea {
  width: 100%; height: 32px; padding: 0 10px;
  background: var(--dsg-surface-2); border: 1px solid var(--dsg-border-soft);
  border-radius: var(--dsg-radius-xs); color: var(--dsg-text); font-size: 13px;
}
.adj-field textarea { height: auto; min-height: 56px; padding: 8px 10px; resize: vertical; font-family: var(--dsg-mono); font-size: 12px; }
.adj-field input:focus, .adj-field select:focus, .adj-field textarea:focus {
  outline: none; border-color: var(--dsg-accent);
}

.adj-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.adj-note {
  font-size: 12px; color: var(--dsg-faint); line-height: 1.55;
  background: var(--dsg-surface-2); border: 1px solid var(--dsg-border-soft);
  border-radius: var(--dsg-radius-sm); padding: 10px 12px;
}
.adj-note strong { color: var(--dsg-sub); }

.adj-toggle { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px; font-size: 13px; color: var(--dsg-sub); }
.adj-toggle input { accent-color: var(--dsg-accent); }

.badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px;
  border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
}
.badge-ok { color: var(--dsg-ok); background: var(--dsg-ok-soft); }
.badge-warn { color: var(--dsg-warn); background: var(--dsg-warn-soft); }
.badge-neutral { color: var(--dsg-sub); background: var(--dsg-surface-3); }

/* ---------- 미리보기 영역 ---------- */

#preview-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--dsg-bg); }

#pv-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--dsg-border-soft); flex: none;
}
.pv-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
#pv-project-name { font-weight: 700; font-size: 14px; white-space: nowrap; }
.pv-source-url {
  font-size: 12px; color: var(--dsg-faint); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

.seg { display: inline-flex; background: var(--dsg-surface-2); border: 1px solid var(--dsg-border-soft); border-radius: 8px; padding: 2px; }
.seg + .seg { margin-left: 8px; }
.seg-btn { height: 26px; padding: 0 12px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--dsg-sub); }
.seg-btn.is-active { background: var(--dsg-surface-3); color: var(--dsg-text); }
.pv-toolbar-actions { display: flex; align-items: center; }

/* 뷰포트 시뮬레이션 — 캔버스 폭 제한 */
#pv-canvas { transition: background .2s, color .2s, max-width .25s ease; }
#pv-canvas.pv-vp-tablet { max-width: 720px; }
#pv-canvas.pv-vp-phone { max-width: 400px; }

/* 반응형 타이포 메타 칩 */
.type-resp { display: inline-flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.type-resp-chip {
  font-size: 10px; font-family: var(--dsg-mono); font-weight: 700;
  padding: 1px 6px; border-radius: 4px;
  background: var(--p-primary-soft, rgba(76,141,255,.12));
  color: var(--p-primary, #4c8dff);
  opacity: .85;
}

#pv-scroll { flex: 1; overflow: auto; padding: 22px; }
#pv-canvas {
  max-width: 980px; margin: 0 auto;
  border-radius: 16px; border: 1px solid var(--dsg-border-soft);
  overflow: hidden;
  transition: background .2s, color .2s;
}

/* --- 캔버스 테마 기반 (추출 토큰 --p-* 적용) --- */

#pv-canvas[data-theme="light"] {
  background: var(--p-bg, #ffffff);
  color: var(--p-text-body, #22272e);
}
#pv-canvas[data-theme="dark"] {
  background: var(--p-bg-dark, #0d1117);
  color: var(--p-text-body-dark, #d6dde6);
}

.pv-section { padding: 34px 40px 40px; }
.pv-section + .pv-section { border-top: 1px solid var(--p-border, rgba(0,0,0,.08)); }
#pv-canvas[data-theme="dark"] .pv-section + .pv-section { border-top-color: var(--p-border-dark, rgba(255,255,255,.1)); }

.pv-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.pv-section-title { font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .55; }
.pv-section-meta { font-size: 12px; opacity: .5; font-family: var(--dsg-mono); }

/* 타이포그래피 스펙imen */
.type-row {
  display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: baseline;
  padding: 14px 0; border-bottom: 1px dashed var(--p-border, rgba(0,0,0,.08));
}
#pv-canvas[data-theme="dark"] .type-row { border-bottom-color: var(--p-border-dark, rgba(255,255,255,.12)); }
.type-row:last-child { border-bottom: none; }
.type-meta { font-size: 12px; font-family: var(--dsg-mono); opacity: .55; line-height: 1.7; }
.type-sample { overflow-wrap: break-word; }

/* 컬러 스와치 */
.sw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.sw {
  border-radius: 12px; overflow: hidden; cursor: pointer; text-align: left;
  border: 1px solid var(--p-border, rgba(0,0,0,.08));
  transition: transform .12s;
}
.sw:hover { transform: translateY(-2px); }
.sw-chip { height: 64px; }
.sw-info { padding: 8px 10px 9px; background: var(--p-surface, rgba(0,0,0,.02)); }
#pv-canvas[data-theme="dark"] .sw-info { background: var(--p-surface-dark, rgba(255,255,255,.04)); }
.sw-name { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.sw-hex { font-size: 11px; font-family: var(--dsg-mono); opacity: .6; }
.sw-var { font-size: 10px; font-family: var(--dsg-mono); opacity: .4; }
.pv-group-label {
  font-size: 12px; font-weight: 700; margin: 18px 0 10px; opacity: .65;
}
.pv-group-label:first-child { margin-top: 0; }

/* 폰트 카드 */
.font-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.font-card {
  border: 1px solid var(--p-border, rgba(0,0,0,.08));
  border-radius: 14px; padding: 18px 20px;
  background: var(--p-surface, rgba(0,0,0,.02));
}
#pv-canvas[data-theme="dark"] .font-card { border-color: var(--p-border-dark, rgba(255,255,255,.12)); background: var(--p-surface-dark, rgba(255,255,255,.04)); }
.font-card-aa { font-size: 44px; line-height: 1.1; margin-bottom: 10px; }
.font-card-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.font-card-meta { font-size: 11.5px; font-family: var(--dsg-mono); opacity: .55; margin-bottom: 10px; }
.font-weights { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; }

/* 스페이싱·라디우스·섀도 */
.dim-list { display: flex; flex-direction: column; gap: 8px; }
.dim-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; font-size: 12px; }
.dim-row .dim-id { font-family: var(--dsg-mono); opacity: .6; }
.dim-row .dim-bar { height: 12px; border-radius: 3px; background: var(--p-primary, #4c8dff); opacity: .8; }
.dim-row .dim-val { font-family: var(--dsg-mono); opacity: .55; }

.radius-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; margin-top: 18px; }
.radius-box {
  height: 76px; display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 8px; font-size: 11px; font-family: var(--dsg-mono);
  background: var(--p-primary, #4c8dff); opacity: .85; color: #fff; font-weight: 700;
}

.shadow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 18px; }
.shadow-card {
  height: 84px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-family: var(--dsg-mono); opacity: .8;
  background: var(--p-surface, #fff);
}
#pv-canvas[data-theme="dark"] .shadow-card { background: var(--p-surface-dark, #1a2029); }

/* 컴포넌트 프리뷰 — 전부 --p-* 토큰 사용 */
.comp-group { margin-bottom: 26px; }
.comp-group-title { font-size: 12px; font-weight: 700; opacity: .6; margin-bottom: 12px; }
.comp-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.pv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 18px; height: 40px; border-radius: var(--p-radius-md, 10px);
  font-weight: 600; font-size: 14px; border: 1px solid transparent; cursor: pointer;
  transition: filter .12s, opacity .12s;
}
.pv-btn:hover { filter: brightness(1.06); }
.pv-btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.pv-btn-lg { height: 48px; padding: 0 24px; font-size: 15px; }
.pv-btn-primary { background: var(--p-primary, #4c8dff); color: var(--p-primary-contrast, #fff); }
.pv-btn-secondary { background: var(--p-secondary, #1f2937); color: var(--p-secondary-contrast, #fff); }
#pv-canvas[data-theme="dark"] .pv-btn-secondary { background: var(--p-secondary-dark, #2a3444); color: var(--p-secondary-contrast-dark, #fff); }
.pv-btn-outline {
  background: transparent; color: var(--p-primary, #4c8dff);
  border-color: var(--p-primary, #4c8dff);
}
.pv-btn-ghost { background: transparent; color: var(--p-text-body, inherit); }
.pv-btn-ghost:hover { background: var(--p-surface, rgba(0,0,0,.05)); }
#pv-canvas[data-theme="dark"] .pv-btn-ghost:hover { background: var(--p-surface-dark, rgba(255,255,255,.07)); }
.pv-btn[disabled] { opacity: .4; cursor: not-allowed; filter: none; }

.pv-field { display: flex; flex-direction: column; gap: 5px; min-width: 220px; }
.pv-field label { font-size: 13px; font-weight: 600; }
.pv-input {
  height: 40px; padding: 0 12px; font-size: 14px;
  border-radius: var(--p-radius-md, 10px);
  border: 1px solid var(--p-border, rgba(0,0,0,.14));
  background: var(--p-surface, #fff); color: inherit;
}
#pv-canvas[data-theme="dark"] .pv-input { background: var(--p-surface-dark, #1a2029); border-color: var(--p-border-dark, rgba(255,255,255,.16)); }
.pv-input:focus { outline: none; border-color: var(--p-primary, #4c8dff); }
.pv-input::placeholder { color: var(--p-text-muted, inherit); opacity: .5; }
.pv-field.is-error .pv-input { border-color: var(--p-danger, #f85149); }
.pv-field-error { font-size: 12px; color: var(--p-danger, #f85149); }

.pv-card {
  max-width: 300px; border-radius: var(--p-radius-lg, 14px);
  border: 1px solid var(--p-border, rgba(0,0,0,.08));
  background: var(--p-surface, #fff); padding: 20px;
}
#pv-canvas[data-theme="dark"] .pv-card { background: var(--p-surface-dark, #1a2029); border-color: var(--p-border-dark, rgba(255,255,255,.12)); }
.pv-card h4 { font-size: 17px; margin-bottom: 8px; font-family: var(--p-font-heading); }
.pv-card p { font-size: 13.5px; opacity: .75; margin-bottom: 14px; line-height: 1.6; }

.pv-badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
}
.pv-badge-primary { background: var(--p-primary-soft, rgba(76,141,255,.15)); color: var(--p-primary, #4c8dff); }
.pv-badge-neutral { background: var(--p-surface, rgba(0,0,0,.06)); color: inherit; opacity: .8; }
#pv-canvas[data-theme="dark"] .pv-badge-neutral { background: var(--p-surface-dark, rgba(255,255,255,.1)); }
.pv-badge-success { background: var(--p-success-soft, rgba(63,185,80,.15)); color: var(--p-success, #2f9e44); }
.pv-badge-warn { background: var(--p-warn-soft, rgba(210,153,34,.15)); color: var(--p-warn, #b07d15); }
.pv-badge-danger { background: var(--p-danger-soft, rgba(248,81,73,.13)); color: var(--p-danger, #f85149); }

.pv-alert {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--p-radius-md, 10px); padding: 13px 15px;
  font-size: 13.5px; border: 1px solid transparent; max-width: 420px;
}
.pv-alert b { display: block; margin-bottom: 2px; }
.pv-alert-success { background: var(--p-success-soft, rgba(63,185,80,.12)); color: var(--p-success, #2f9e44); }
.pv-alert-warn { background: var(--p-warn-soft, rgba(210,153,34,.12)); color: var(--p-warn, #b07d15); }
.pv-alert-danger { background: var(--p-danger-soft, rgba(248,81,73,.1)); color: var(--p-danger, #f85149); }
.pv-alert-info { background: var(--p-primary-soft, rgba(76,141,255,.1)); color: var(--p-primary, #4c8dff); }

/* 폰트 적용 (추출 폰트) */
#pv-canvas, #pv-canvas .pv-btn, #pv-canvas .pv-input { font-family: var(--p-font-body); }
#pv-canvas h1, #pv-canvas h2, #pv-canvas h3, #pv-canvas h4,
#pv-canvas .type-sample, #pv-canvas .font-card-aa { font-family: var(--p-font-heading); }

/* ---------- 토스트 ---------- */

#toast-area {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 1000; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  background: var(--dsg-surface-3); color: var(--dsg-text);
  border: 1px solid var(--dsg-border); border-radius: 10px;
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  animation: toast-in .18s ease-out;
}
.toast.ok { border-color: rgba(63,185,80,.4); }
.toast.warn { border-color: rgba(210,153,34,.4); }
.toast.error { border-color: rgba(248,81,73,.4); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 모달 ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 8, 12, .66);
  display: flex; align-items: center; justify-content: center; z-index: 900;
  backdrop-filter: blur(3px);
}
.modal {
  width: min(640px, calc(100vw - 40px)); max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  background: var(--dsg-surface); border: 1px solid var(--dsg-border);
  border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--dsg-border-soft); flex: none;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--dsg-border-soft); flex: none;
}
.modal textarea {
  width: 100%; min-height: 300px; resize: vertical;
  background: var(--dsg-bg); border: 1px solid var(--dsg-border-soft);
  border-radius: var(--dsg-radius-sm); padding: 10px 12px;
  font-family: var(--dsg-mono); font-size: 12px; line-height: 1.55; color: var(--dsg-text);
}
.modal textarea:focus { outline: none; border-color: var(--dsg-accent); }

/* 내보내기 모달 */
.export-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.export-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--dsg-border-soft); border-radius: var(--dsg-radius-sm);
  background: var(--dsg-surface-2); padding: 10px 14px;
}
.export-item input[type="checkbox"] { accent-color: var(--dsg-accent); width: 16px; height: 16px; flex: none; }
.export-item .ex-name { font-weight: 700; font-size: 13.5px; }
.export-item .ex-desc { font-size: 12px; color: var(--dsg-faint); }
.export-item .ex-main { flex: 1; min-width: 0; }

/* ---------- 신규 컴포넌트: 탭 ---------- */
.pv-tabs { border: 1px solid var(--p-border, rgba(0,0,0,.1)); border-radius: var(--p-radius-lg, 14px); overflow: hidden; max-width: 480px; }
.pv-tab-list { display: flex; border-bottom: 1px solid var(--p-border, rgba(0,0,0,.1)); background: var(--p-surface, rgba(0,0,0,.02)); }
#pv-canvas[data-theme="dark"] .pv-tab-list { background: var(--p-surface-dark, rgba(255,255,255,.04)); border-bottom-color: var(--p-border-dark, rgba(255,255,255,.12)); }
.pv-tab { flex: 1; padding: 11px 16px; font-size: 13.5px; font-weight: 600; color: var(--p-text-sub, inherit); border-bottom: 2px solid transparent; }
.pv-tab:hover { color: var(--p-text-body, inherit); }
.pv-tab.is-active { color: var(--p-primary, #4c8dff); border-bottom-color: var(--p-primary, #4c8dff); }
.pv-tab-panel { padding: 18px 20px; font-size: 14px; line-height: 1.65; display: none; }
.pv-tab-panel.is-active { display: block; }

/* ---------- 신규 컴포넌트: 아코디언 ---------- */
.pv-accordion { display: flex; flex-direction: column; gap: var(--p-stack-gap, 10px); max-width: 480px; }
.pv-acc-item { border: 1px solid var(--p-border, rgba(0,0,0,.1)); border-radius: var(--p-radius-md, 10px); overflow: hidden; background: var(--p-surface-2x, transparent); }
#pv-canvas[data-theme="dark"] .pv-acc-item { border-color: var(--p-border-dark, rgba(255,255,255,.14)); }
.pv-acc-head {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 18px; font-size: 14.5px; font-weight: 600; text-align: left; cursor: pointer;
}
.pv-acc-head:hover { background: var(--p-surface, rgba(0,0,0,.03)); }
#pv-canvas[data-theme="dark"] .pv-acc-head:hover { background: var(--p-surface-dark, rgba(255,255,255,.05)); }
.pv-acc-arrow { transition: transform .2s; font-size: 11px; color: var(--p-text-sub, inherit); flex: none; }
.pv-acc-item.is-open .pv-acc-arrow { transform: rotate(180deg); }
.pv-acc-body { display: none; padding: 0 18px 15px; font-size: 13.5px; line-height: 1.65; opacity: .8; }
.pv-acc-item.is-open .pv-acc-body { display: block; }

/* ---------- 신규 컴포넌트: 캐러셀 ---------- */
.pv-carousel { max-width: 520px; position: relative; }
.pv-carousel-track {
  display: flex; gap: var(--p-widget-gap, 16px); overflow-x: auto; scroll-snap-type: x mandatory;
  padding-bottom: 8px; scrollbar-width: none;
}
.pv-carousel-track::-webkit-scrollbar { display: none; }
.pv-carousel-slide {
  flex: 0 0 72%; scroll-snap-align: center;
  border-radius: var(--p-radius-lg, 14px); padding: 22px 24px;
  background: var(--p-surface, #fff); border: 1px solid var(--p-border, rgba(0,0,0,.08));
  box-shadow: var(--p-shadow-sm, none);
}
#pv-canvas[data-theme="dark"] .pv-carousel-slide { background: var(--p-surface-dark, #1a2029); border-color: var(--p-border-dark, rgba(255,255,255,.12)); }
.pv-carousel-slide h5 { font-size: 16px; margin-bottom: 6px; font-family: var(--p-font-heading); }
.pv-carousel-slide p { font-size: 13px; opacity: .75; line-height: 1.6; }
.pv-carousel-nav { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
.pv-carousel-btn {
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer; font-size: 14px;
  border: 1px solid var(--p-border, rgba(0,0,0,.14)); background: var(--p-surface, #fff); color: inherit;
}
#pv-canvas[data-theme="dark"] .pv-carousel-btn { background: var(--p-surface-dark, #1a2029); border-color: var(--p-border-dark, rgba(255,255,255,.18)); }
.pv-carousel-btn:hover { border-color: var(--p-primary, #4c8dff); color: var(--p-primary, #4c8dff); }
.pv-carousel-dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.pv-carousel-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--p-border-medium, #cfd4da); opacity: .6; }
.pv-carousel-dot.is-active { background: var(--p-primary, #4c8dff); opacity: 1; width: 18px; }

/* ---------- 신규 컴포넌트: 폼 (스위치·체크·라디오·셀렉트) ---------- */
.pv-form-row { display: flex; flex-wrap: wrap; gap: 22px; align-items: center; }
.pv-form-item { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.pv-switch { position: relative; width: 42px; height: 24px; flex: none; cursor: pointer; }
.pv-switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pv-switch-track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--p-border-medium, #cfd4da); transition: background .18s;
}
.pv-switch-knob {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .18s;
}
.pv-switch input:checked ~ .pv-switch-track { background: var(--p-primary, #4c8dff); }
.pv-switch input:checked ~ .pv-switch-knob { left: 21px; }
.pv-check, .pv-radio { width: 18px; height: 18px; accent-color: var(--p-primary, #4c8dff); flex: none; cursor: pointer; }
.pv-select {
  height: 38px; padding: 0 12px; font-size: 13.5px; border-radius: var(--p-radius-md, 10px);
  border: 1px solid var(--p-border, rgba(0,0,0,.14)); background: var(--p-surface, #fff); color: inherit; cursor: pointer;
}
#pv-canvas[data-theme="dark"] .pv-select { background: var(--p-surface-dark, #1a2029); border-color: var(--p-border-dark, rgba(255,255,255,.16)); }

/* ---------- 신규 컴포넌트: 내비게이션 (브레드크럼·페이지네이션) ---------- */
.pv-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.pv-breadcrumb a { color: var(--p-primary, #4c8dff); text-decoration: none; }
.pv-breadcrumb a:hover { text-decoration: underline; }
.pv-breadcrumb .sep { opacity: .4; }
.pv-breadcrumb .current { color: var(--p-text-sub, inherit); }
.pv-pagination { display: flex; gap: 6px; align-items: center; }
.pv-page {
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--p-radius-md, 8px);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--p-border, rgba(0,0,0,.12)); background: transparent; color: inherit;
}
.pv-page:hover:not(.is-current):not([disabled]) { border-color: var(--p-primary, #4c8dff); color: var(--p-primary, #4c8dff); }
.pv-page.is-current { background: var(--p-primary, #4c8dff); color: var(--p-primary-contrast, #fff); border-color: transparent; }
.pv-page[disabled] { opacity: .35; cursor: not-allowed; }
.pv-page-ellipsis { opacity: .5; padding: 0 2px; }

/* ---------- 신규 컴포넌트: 데이터 (테이블·프로그레스) ---------- */
.pv-table-wrap { border: 1px solid var(--p-border, rgba(0,0,0,.1)); border-radius: var(--p-radius-lg, 12px); overflow: hidden; max-width: 520px; }
.pv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pv-table th {
  text-align: left; padding: 11px 16px; font-size: 12px; font-weight: 700;
  background: var(--p-surface, rgba(0,0,0,.03)); color: var(--p-text-sub, inherit);
}
#pv-canvas[data-theme="dark"] .pv-table th { background: var(--p-surface-dark, rgba(255,255,255,.05)); }
.pv-table td { padding: 11px 16px; border-top: 1px solid var(--p-border, rgba(0,0,0,.07)); }
#pv-canvas[data-theme="dark"] .pv-table td { border-top-color: var(--p-border-dark, rgba(255,255,255,.09)); }
.pv-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pv-progress { width: 100%; max-width: 360px; }
.pv-progress-label { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; color: var(--p-text-sub, inherit); }
.pv-progress-track { height: 8px; border-radius: 999px; background: var(--p-border-light, #e3e6ea); overflow: hidden; }
#pv-canvas[data-theme="dark"] .pv-progress-track { background: rgba(255,255,255,.12); }
.pv-progress-bar { height: 100%; border-radius: 999px; background: var(--p-primary, #4c8dff); transition: width .3s; }

/* ---------- 신규 컴포넌트: 기타 (아바타·디바이더·칩) ---------- */
.pv-avatar-row { display: flex; align-items: center; gap: calc(var(--p-stack-gap, 12px) * .75); }
.pv-avatar {
  border-radius: 999px; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: var(--p-primary-soft, rgba(76,141,255,.15)); color: var(--p-primary, #4c8dff);
  font-weight: 700; font-size: 13px; border: 2px solid var(--p-surface, #fff);
}
#pv-canvas[data-theme="dark"] .pv-avatar { border-color: var(--p-surface-dark, #1a2029); }
.pv-divider { border: none; border-top: 1px solid var(--p-border, rgba(0,0,0,.1)); margin: 0; }
#pv-canvas[data-theme="dark"] .pv-divider { border-top-color: var(--p-border-dark, rgba(255,255,255,.14)); }
.pv-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; cursor: default;
  background: var(--p-primary-soft, rgba(76,141,255,.13)); color: var(--p-primary, #4c8dff);
}
.pv-chip-x {
  width: 18px; height: 18px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; background: rgba(0,0,0,.08); color: inherit; cursor: pointer; border: none;
}
.pv-chip-x:hover { background: rgba(0,0,0,.16); }
#pv-canvas[data-theme="dark"] .pv-chip-x { background: rgba(255,255,255,.14); }
#pv-canvas[data-theme="dark"] .pv-chip-x:hover { background: rgba(255,255,255,.24); }

/* ---------- 레이아웃 스펙imen (컨테이너 폭·섹션 여백·간격) ---------- */
.layout-viz { margin-top: 8px; }
.layout-canvas-frame {
  position: relative; height: 120px; border: 1px dashed var(--p-border-medium, #cfd4da);
  border-radius: 8px; overflow: hidden; background: var(--p-surface, rgba(0,0,0,.02));
}
#pv-canvas[data-theme="dark"] .layout-canvas-frame { background: var(--p-surface-dark, rgba(255,255,255,.03)); }
.layout-container-bar {
  position: absolute; top: 18px; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--p-primary, #4c8dff); opacity: .18; border-radius: 4px;
}
.layout-container-label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-family: var(--dsg-mono); font-size: 11.5px; font-weight: 700; color: var(--p-primary, #4c8dff);
}
.layout-pad-box {
  border: 1px solid var(--p-border, rgba(0,0,0,.12)); border-radius: 8px; overflow: hidden; max-width: 420px;
}
#pv-canvas[data-theme="dark"] .layout-pad-box { border-color: var(--p-border-dark, rgba(255,255,255,.16)); }
.layout-pad-fill { background: repeating-linear-gradient(45deg, var(--p-primary-soft, rgba(76,141,255,.2)), var(--p-primary-soft, rgba(76,141,255,.2)) 6px, transparent 6px, transparent 12px); }
.layout-pad-content { background: var(--p-bg, #fff); padding: 10px 16px; font-size: 12.5px; text-align: center; opacity: .8; }
#pv-canvas[data-theme="dark"] .layout-pad-content { background: var(--p-bg-dark, #10141a); }
.layout-gap-demo { display: flex; max-width: 360px; }
.layout-gap-demo > .layout-gap-cell {
  flex: 1; height: 56px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-family: var(--dsg-mono);
  background: var(--p-primary, #4c8dff); color: #fff; font-weight: 700; opacity: .85;
}
.layout-gap-rule { height: 18px; display: flex; align-items: center; justify-content: center; font-size: 10px; font-family: var(--dsg-mono); color: var(--p-primary, #4c8dff); font-weight: 700; position: relative; }
.layout-gap-rule::before, .layout-gap-rule::after { content: ''; position: absolute; top: 50%; width: 100%; border-top: 1px dashed var(--p-primary, #4c8dff); opacity: .5; }
.layout-gap-rule span { background: var(--p-bg, #fff); padding: 0 6px; position: relative; }
#pv-canvas[data-theme="dark"] .layout-gap-rule span { background: var(--p-bg-dark, #10141a); }
.layout-viz-meta { font-size: 11.5px; font-family: var(--dsg-mono); opacity: .6; margin-top: 6px; }



@media (max-width: 1280px) {
  :root { --dsg-side-w: 330px; }
  .brand-sub { display: none; }
  .pv-section { padding: 28px 28px 32px; }
}

@media (max-width: 960px) {
  body { overflow: auto; }
  #app { height: auto; }
  #app-main { flex-direction: column; }
  #side-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--dsg-border-soft); }
  .adjust-pane { max-height: 420px; }
  .url-form { flex-wrap: wrap; }
  #app-header { height: auto; padding: 10px 14px; flex-wrap: wrap; }
  .type-row { grid-template-columns: 1fr; }
}
