:root {
  --bg-base: #0B0B0D;
  --bg-surface: #111114;
  --bg-elevated: #17171B;
  --bg-hover: #1D1D22;
  --bg-active: #24242A;

  --border-subtle: rgba(255,255,255,0.05);
  --border-default: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.15);

  --text-primary: rgba(255,255,255,0.93);
  --text-secondary: rgba(255,255,255,0.64);
  --text-tertiary: rgba(255,255,255,0.42);
  --text-muted: rgba(255,255,255,0.26);

  --ic-red: #FF7474;
  --ic-yellow: #FFBA5C;
  --ic-blue: #7AABF7;
  --ic-green: #66D28C;

  --rel-color: #6EB0E6;
  --roll-color: #B49EE0;

  --font-sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

button { font: inherit; color: inherit; }
textarea { font: inherit; color: inherit; }

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

/* ===================== TOPBAR ===================== */
.topbar {
  height: 44px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; letter-spacing: -0.02em; }
.brand-mark {
  width: 20px; height: 20px;
  background: var(--ic-blue);
  border-radius: 5px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark::after {
  content: '';
  width: 8px; height: 8px;
  background: var(--bg-base);
  border-radius: 1.5px;
}
.brand-name { color: var(--text-primary); }
.brand-sub { color: var(--text-tertiary); font-weight: 400; }

.tb-divider { width: 1px; height: 14px; background: var(--border-default); }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); }
.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb-current {
  color: var(--text-primary);
  padding: 3px 7px;
  border-radius: 4px;
  cursor: text;
  transition: background 120ms ease, box-shadow 120ms ease;
  outline: none;
  min-width: 40px;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.breadcrumb-current:hover { background: var(--bg-hover); }
.breadcrumb-current:focus {
  background: var(--bg-elevated);
  box-shadow: inset 0 0 0 1px var(--ic-blue);
  overflow: visible;
}
.schema-rename-input {
  flex: 1; min-width: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--ic-blue);
  border-radius: 4px;
  color: var(--text-primary);
  font: inherit;
  padding: 1px 6px;
  outline: none;
}

.tb-spacer { flex: 1; }

.tb-btn {
  height: 28px;
  padding: 0 11px;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
}
.tb-btn:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--bg-hover); }
.tb-btn.primary {
  background: var(--text-primary);
  color: var(--bg-base);
  border-color: var(--text-primary);
  font-weight: 500;
}
.tb-btn.primary:hover { opacity: 0.88; }

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  color: var(--text-tertiary);
  margin-left: 4px;
}

/* 휴지통 모달 */
.trash-modal-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}
.trash-modal-empty .empty-ico { font-size: 36px; opacity: 0.3; margin-bottom: 8px; display: block; }
.trash-modal-list { display: flex; flex-direction: column; gap: 6px; }
.trash-modal-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  transition: border-color 150ms ease;
}
.trash-modal-item:hover { border-color: var(--border-default); }
.trash-modal-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trash-modal-item-name { color: var(--text-primary); font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-modal-item-meta { color: var(--text-muted); font-size: 11px; font-family: var(--font-mono); }
.trash-modal-restore {
  padding: 5px 10px;
  background: rgba(122,171,247,0.1);
  border: 1px solid rgba(122,171,247,0.25);
  border-radius: 5px;
  color: var(--ic-blue);
  font-size: 11.5px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 150ms ease;
  flex-shrink: 0;
}
.trash-modal-restore:hover { background: rgba(122,171,247,0.18); }
.trash-modal-purge {
  width: 26px; height: 26px;
  background: transparent;
  border: 1px solid rgba(255,116,116,0.2);
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  transition: all 150ms ease;
}
.trash-modal-purge:hover { color: var(--ic-red); background: rgba(255,116,116,0.1); border-color: var(--ic-red); }

/* 사용자 영역 (로그인/로그아웃) */
#authArea { display: flex; align-items: center; gap: 6px; }
.user-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  background: rgba(122,171,247,0.08);
  border: 1px solid rgba(122,171,247,0.2);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: default;
}
.user-pill .user-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ic-green);
}
.btn-logout {
  margin-left: 2px;
  width: 18px; height: 18px;
  background: transparent; border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-logout:hover { background: rgba(255,116,116,0.1); color: var(--ic-red); }

/* 플랜 배지 — user-pill 옆에 표시. 사용량(used/max) 도 같은 pill 안에 */
.plan-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: default;
  margin-right: 6px;
  letter-spacing: 0.02em;
}
.plan-pill.plan-free {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary);
}
.plan-pill.plan-pro {
  background: rgba(255,186,92,0.12);
  border: 1px solid rgba(255,186,92,0.32);
  color: var(--ic-yellow);
}
.plan-pill .plan-pill-sep { color: var(--text-muted); }
.plan-pill .plan-pill-cap { color: var(--ic-red); font-weight: 600; }
.modal-link-btn {
  background: transparent;
  border: 0;
  color: var(--ic-blue);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  font-family: var(--font-sans);
  text-decoration: underline;
}
.modal-link-btn:hover { opacity: 0.8; }

/* ===================== WORKSPACE ===================== */
.workspace { flex: 1; display: flex; min-height: 0; }

/* ===================== RAIL (Make-style icon nav) ===================== */
.rail {
  width: 64px;
  background: #0A0A0C;
  border-right: 1px solid var(--border-subtle);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  gap: 2px;
}
.rail-item {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 10px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--text-tertiary);
  text-align: center;
  border-left: 2px solid transparent;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.rail-item:hover { background: rgba(255,255,255,0.03); color: var(--text-secondary); }
.rail-item.active {
  color: var(--text-primary);
  background: rgba(122,171,247,0.07);
  border-left-color: var(--ic-blue);
}
.rail-ico {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
}
.rail-ico svg { width: 18px; height: 18px; }
.rail-label {
  font-size: 9.5px;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

/* ===================== PAGE ROUTING ===================== */
.page {
  flex: 1;
  display: none;
  min-width: 0;
  min-height: 0;
}
.page.active { display: flex; }

/* ===================== SECONDARY PANEL (only on 내 스키마) ===================== */
.secondary {
  width: 220px;
  background: #0F0F11;
  border-right: 1px solid var(--border-subtle);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 8px 16px;
  transition: width 200ms ease, padding 200ms ease;
}
.secondary.collapsed {
  width: 28px;
  padding: 12px 0;
}
.sec-head {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px 10px;
  display: flex; align-items: center;
  cursor: pointer;
  border-radius: 5px;
  transition: color 150ms ease, background 150ms ease;
  user-select: none;
}
.sec-head:hover { color: var(--text-secondary); background: rgba(255,255,255,0.03); }
.secondary.collapsed .sec-head {
  padding: 4px 6px;
  justify-content: center;
}
.sec-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sec-count {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-right: 6px;
}
.sec-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 200ms ease;
  display: inline-flex;
  width: 12px;
  justify-content: center;
}
.secondary.collapsed .sec-chevron { transform: rotate(-90deg); }
/* 접혔을 때 본문 (버튼·리스트) 숨김 */
.secondary.collapsed .sec-title,
.secondary.collapsed .sec-count,
.secondary.collapsed #schemaList,
.secondary.collapsed #btnAddSchema,
.secondary.collapsed #btnImportUrl,
.secondary.collapsed #trashSection { display: none; }

/* 휴지통 섹션 */
.trash-section {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}
.trash-head {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  user-select: none;
  transition: color 150ms ease, background 150ms ease;
}
.trash-head:hover { background: rgba(255,255,255,0.03); color: var(--text-tertiary); }
.trash-head .sec-chevron { font-size: 9px; transition: transform 200ms ease; }
.trash-section.collapsed .sec-chevron { transform: rotate(-90deg); }
.trash-section.collapsed .trash-body { display: none; }
.trash-body { padding: 4px 0 4px; }

.trash-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-tertiary);
  border-radius: 5px;
  margin: 1px 0;
}
.trash-item:hover { background: rgba(255,255,255,0.03); color: var(--text-secondary); }
.trash-item-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trash-item-actions { display: inline-flex; gap: 2px; flex-shrink: 0; }
.trash-restore, .trash-purge {
  width: 20px; height: 20px;
  background: transparent; border: 0;
  cursor: pointer; padding: 0;
  border-radius: 3px;
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
  font-family: var(--font-sans);
  line-height: 1;
}
.trash-item:hover .trash-restore,
.trash-item:hover .trash-purge { opacity: 1; }
.trash-restore:hover { color: var(--ic-blue);  background: rgba(122,171,247,0.1); }
.trash-purge:hover   { color: var(--ic-red);   background: rgba(255,116,116,0.1); }
.trash-empty { padding: 8px 12px; color: var(--text-muted); font-size: 11px; text-align: center; line-height: 1.5; }

/* + 새 스키마 버튼 */
.btn-add-schema {
  display: block;
  width: calc(100% - 4px);
  margin: 2px 2px 4px;
  padding: 7px 10px;
  background: var(--ic-blue);
  color: var(--bg-base);
  border: 0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  text-align: left;
  transition: opacity 150ms ease;
}
.btn-add-schema:hover { opacity: 0.88; }

/* Notion URL 에서 가져오기 — 보조 버튼 */
.btn-import-url {
  display: flex;
  align-items: center;
  gap: 7px;
  width: calc(100% - 4px);
  margin: 0 2px 8px;
  padding: 6px 10px;
  background: transparent;
  color: var(--text-tertiary);
  border: 1px dashed var(--border-default);
  border-radius: 6px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: var(--font-sans);
  text-align: left;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}
.btn-import-url:hover {
  border-color: var(--ic-blue);
  color: var(--text-primary);
  background: rgba(122,171,247,0.06);
}
.btn-import-url svg { width: 12px; height: 12px; flex-shrink: 0; }

/* 스키마 리스트 — 남는 공간을 차지하며 스크롤. 휴지통은 항상 맨 아래 고정 */
#schemaList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -2px;
  padding: 0 2px;
}
#schemaList::-webkit-scrollbar { width: 6px; }
#schemaList::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
#schemaList::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* 사이드바 하단 휴지통 (노션 위치) */
.sidebar-trash {
  margin: 8px 2px 0;
  padding: 10px 10px 7px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: background 150ms ease, color 150ms ease;
  text-align: left;
  flex-shrink: 0;
  border-radius: 6px;
}
.sidebar-trash:hover { background: rgba(255,255,255,0.03); color: var(--text-primary); }
.sidebar-trash-ico {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sidebar-trash:hover .sidebar-trash-ico { color: var(--text-secondary); }
.sidebar-trash-ico svg { width: 14px; height: 14px; }
.sidebar-trash-label { flex: 1; min-width: 0; }
.sidebar-trash-count {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 10.5px;
  min-width: 16px;
  padding: 1px 5px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  text-align: center;
  line-height: 1.2;
}
.sidebar-trash-count.empty { display: none; }
.secondary.collapsed .sidebar-trash { display: none; }

/* Schema list item */
.schema-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px;
  margin: 1px 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 150ms ease, color 150ms ease;
}
.schema-item:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.schema-item.active { background: var(--bg-active); color: var(--text-primary); }
.schema-item-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}
.schema-item-del {
  width: 18px; height: 18px;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
  flex-shrink: 0;
}
.schema-item:hover .schema-item-del { opacity: 1; }
.schema-item-del:hover { color: var(--ic-red); background: rgba(255,116,116,0.1); }

/* ===================== TEMPLATES GALLERY ===================== */
.gallery {
  flex: 1;
  background: var(--bg-base);
  overflow-y: auto;
  padding: 36px 40px 60px;
}
.gallery-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.gallery-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  max-width: 1200px;
}
.tpl-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
  min-height: 200px;
  cursor: pointer;
}
.tpl-card:hover { border-color: var(--border-strong); transform: translateY(-1px); background: var(--bg-hover); }
.tpl-card.placeholder { cursor: not-allowed; }
.tpl-card .db-ico.lg {
  width: 44px; height: 44px;
  border-radius: 10px;
}
.tpl-card-title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); }
.tpl-card-desc { font-size: 12.5px; color: var(--text-tertiary); line-height: 1.5; flex: 1; }
.tpl-card-meta {
  display: flex;
  gap: 12px;
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 4px;
}
.tpl-card-meta-rel { color: var(--rel-color); }
.tpl-card-meta-roll { color: var(--roll-color); }
.tpl-card-btn {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--text-primary);
  color: var(--bg-base);
  border: 0;
  border-radius: 6px;
  font-weight: 500;
  font-size: 12.5px;
  cursor: pointer;
  transition: opacity 150ms ease;
  font-family: var(--font-sans);
}
.tpl-card-btn:hover { opacity: 0.88; }
.tpl-card.placeholder { opacity: 0.6; }
.tpl-card.placeholder .tpl-card-btn {
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: default;
}
.tpl-card.placeholder .tpl-card-btn:hover { opacity: 1; }

/* ===================== EMPTY PAGE (설정) ===================== */
.empty-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg-base);
}
.empty-ico {
  font-size: 56px;
  opacity: 0.25;
  line-height: 1;
}
.empty-msg {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.empty-sub {
  color: var(--text-muted);
  font-size: 12.5px;
}

/* ===================== DB ICON CHIP (그대로 유지) ===================== */
.db-ico {
  width: 20px; height: 20px;
  border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.db-ico svg { width: 12px; height: 12px; }
.db-ico.lg { width: 34px; height: 34px; border-radius: 7px; }
.db-ico.lg svg { width: 18px; height: 18px; }
.db-ico.tiny { width: 16px; height: 16px; border-radius: 3px; }
.db-ico.tiny svg { width: 10px; height: 10px; }

.ic-red-bg    { background: rgba(255,116,116,0.15); color: var(--ic-red); }
.ic-orange-bg { background: rgba(255,158,89,0.15);  color: #FFB585; }
.ic-yellow-bg { background: rgba(255,186,92,0.15);  color: var(--ic-yellow); }
.ic-green-bg  { background: rgba(102,210,140,0.15); color: var(--ic-green); }
.ic-teal-bg   { background: rgba(102,205,205,0.15); color: #88DDDB; }
.ic-blue-bg   { background: rgba(122,171,247,0.15); color: var(--ic-blue); }
.ic-purple-bg { background: rgba(180,158,224,0.15); color: #C4B2E8; }
.ic-pink-bg   { background: rgba(240,150,200,0.15); color: #F0ADCD; }
.ic-brown-bg  { background: rgba(180,138,106,0.15); color: #C9A58E; }
.ic-gray-bg   { background: rgba(155,155,158,0.15); color: #C8C8CE; }

/* ===================== CANVAS ROW (canvas + edit panel side-by-side) ===================== */
.canvas-row {
  flex: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
}

/* ===================== CANVAS ===================== */
.canvas {
  flex: 1;
  min-height: 320px;
  background: var(--bg-surface);
  position: relative;
  overflow: hidden;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.04) 1px, transparent 0);
  background-size: 24px 24px;
  background-position: 0 0;
}

.cv-head {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 12px 16px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--bg-surface) 0%, rgba(17,17,20,0.8) 70%, transparent 100%);
}
.cv-title {
  font-size: 11.5px;
  color: var(--text-tertiary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 500;
}
.cv-count {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.cv-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* 카드 컨테이너 — Cmd+휠 줌이 적용되는 대상 */
#cvCards {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  /* transform 은 JS 가 동적으로 설정 (translate + scale) */
}

/* 줌 인디케이터 (좌하단) */
.zoom-indicator {
  position: absolute;
  bottom: 14px;
  left: 14px;
  padding: 5px 10px;
  background: rgba(23,23,27,0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-mono);
  z-index: 20;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
  user-select: none;
}
.zoom-indicator:hover { color: var(--text-primary); border-color: var(--border-strong); }
.zoom-input {
  width: 36px;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: right;
  outline: none;
  padding: 0;
}
.canvas.panning { cursor: grabbing !important; }
.canvas.panning #cvCards * { pointer-events: none; }

.legend {
  position: absolute;
  bottom: 14px;
  right: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: rgba(23,23,27,0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
}
.legend-item {
  display: flex; align-items: center; gap: 8px;
}
.legend-swatch { width: 22px; height: 0; border-top: 1.5px solid transparent; }
.legend-rel {
  border: 0;
  height: 2px;
  background: linear-gradient(to right, #6EB0E6, #88DDA6, #F4D372, #F08C8C, #C4B2E8);
  border-radius: 1px;
}
.legend-roll { border-top: 1.5px dashed var(--roll-color); }

/* Canvas DB cards */
.dbcard {
  position: absolute;
  width: 186px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 9px;
  cursor: grab;
  overflow: hidden;
  z-index: 10;
  transition: border-color 0.15s ease, transform 0.18s ease, box-shadow 0.15s ease;
  touch-action: none;
}
.dbcard:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.dbcard.active {
  border-color: var(--ic-blue);
  box-shadow: 0 0 0 3px rgba(122,171,247,0.12);
}
.dbcard.dragging {
  cursor: grabbing;
  z-index: 50;
  transform: none !important;
  transition: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  user-select: none;
}
.dbcard-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-hover);
}
.dbcard-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: -0.01em;
}
.dbcard-count {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.dbcard-props {
  padding: 4px 0 6px;
}
.dbcard-prop {
  display: flex; align-items: center; gap: 9px;
  padding: 3.5px 11px;
  font-size: 11.5px;
  color: var(--text-secondary);
  cursor: default;
}
.dbcard-prop-ico {
  width: 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.dbcard-prop-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dbcard-prop.is-rel { color: var(--pair-color, var(--rel-color)); }
.dbcard-prop.is-rel .dbcard-prop-ico { color: var(--pair-color, var(--rel-color)); opacity: 0.65; }
.dbcard-prop.is-roll { color: var(--pair-color, var(--roll-color)); }
.dbcard-prop.is-roll .dbcard-prop-ico { color: var(--pair-color, var(--roll-color)); opacity: 0.65; }

/* ===================== EDIT PANEL (right slide-in + resizable) ===================== */
.edit-panel {
  --panel-w: 400px;       /* JS가 리사이저로 동적 변경 */
  flex-shrink: 0;
  width: 0;
  overflow: hidden;
  background: var(--bg-base);
  border-left: 1px solid var(--border-default);
  transition: width 220ms ease;
}
.edit-panel.open { width: var(--panel-w); }
.edit-panel-inner {
  width: var(--panel-w);  /* 외부 폭과 동기 */
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;     /* resizer absolute 기준 */
}
/* 좌측 resizer 핸들 — 드래그로 패널 폭 조정 */
.edit-panel-resizer {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  transition: background 150ms ease;
  z-index: 30;
  touch-action: none;
}
.edit-panel-resizer::after {
  content: '';
  position: absolute;
  left: 2px; top: 50%;
  width: 2px; height: 32px;
  margin-top: -16px;
  background: var(--border-default);
  border-radius: 1px;
  transition: background 150ms ease;
}
.edit-panel-resizer:hover::after,
.edit-panel-resizer.dragging::after { background: var(--ic-blue); }
.edit-panel-resizer:hover,
.edit-panel-resizer.dragging { background: rgba(122,171,247,0.08); }
.edit-panel-head {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: var(--bg-surface);
}
.edit-panel-head-title {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.edit-panel-close {
  margin-left: auto;
  width: 28px; height: 28px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, color 150ms ease;
}
.edit-panel-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.edit-panel-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-base);
}

/* ── Preview 내부 (renderPreview가 #preview에 그리는 마크업) — 패널 폭에 맞춰 조정 ── */
.pv-head-bar {
  padding: 18px 22px 4px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 편집 가능 인풋 (이름/설명) */
.edit-name {
  flex: 1; min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
  padding: 4px 6px;
  border-radius: 4px;
  outline: none;
  font-family: var(--font-sans);
  transition: background 150ms ease;
}
.edit-name:hover { background: rgba(255,255,255,0.04); }
.edit-name:focus { background: rgba(255,255,255,0.06); }
.edit-desc {
  display: block;
  width: calc(100% - 44px);
  margin: 2px 22px 8px;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 4px 6px;
  border-radius: 4px;
  font-family: var(--font-sans);
  outline: none;
  resize: none;
  transition: background 150ms ease;
}
.edit-desc:hover { background: rgba(255,255,255,0.04); }
.edit-desc:focus { background: rgba(255,255,255,0.06); }

/* 아이콘/색 picker 행 — 패널 폭 변화에 반응하게.
   1) 같은 줄에 둘 다 들어갈 때는 양쪽이 공간 공유 (flex:1)
   2) 좁아지면 각 그룹 안에서 셀이 다음 줄로 랩 (grid auto-fit)
   3) 더 좁아지면 두 그룹이 세로로 쌓임 (flex-wrap) */
.edit-style-row {
  display: flex;
  gap: 18px;
  padding: 6px 22px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.edit-style-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1 1 220px;    /* 양쪽이 각각 최소 220px 확보, 패널 좁아지면 세로 쌓임 */
}
.edit-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}
.icon-picker {
  display: grid;
  /* 그룹 폭에 들어갈 수 있는 만큼만 22px 컬럼 — 좁아지면 다음 줄로 랩 */
  grid-template-columns: repeat(auto-fit, 22px);
  gap: 4px;
  justify-content: start;
  max-width: 100%;
}
.icon-pick {
  width: 22px; height: 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 5px;
  color: var(--text-tertiary);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 150ms ease;
  padding: 0;
}
.icon-pick svg { width: 11px; height: 11px; }
.icon-pick:hover { border-color: var(--border-strong); color: var(--text-secondary); }
.icon-pick.active {
  border-color: var(--ic-blue);
  background: rgba(122,171,247,0.1);
  color: var(--text-primary);
}
.color-picker {
  display: grid;
  /* 그룹 폭에 맞춰 18px 컬럼 자동 랩 */
  grid-template-columns: repeat(auto-fit, 18px);
  gap: 5px;
  justify-content: start;
  align-items: center;
  max-width: 100%;
}
.color-pick {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: all 150ms ease;
}
.color-pick.swatch-red    { background: rgba(255,116,116,0.45); }
.color-pick.swatch-orange { background: rgba(255,158,89,0.45); }
.color-pick.swatch-yellow { background: rgba(255,186,92,0.45); }
.color-pick.swatch-green  { background: rgba(102,210,140,0.45); }
.color-pick.swatch-teal   { background: rgba(102,205,205,0.45); }
.color-pick.swatch-blue   { background: rgba(122,171,247,0.45); }
.color-pick.swatch-purple { background: rgba(180,158,224,0.45); }
.color-pick.swatch-pink   { background: rgba(240,150,200,0.45); }
.color-pick.swatch-brown  { background: rgba(180,138,106,0.45); }
.color-pick.swatch-gray   { background: rgba(155,155,158,0.45); }
.color-pick:hover { transform: scale(1.1); }
.color-pick.active { border-color: var(--text-primary); }

/* 패널 푸터 (DB 삭제 등 destructive) */
.edit-actions {
  padding: 16px 22px 24px;
  display: flex; justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 8px;
}
.btn-delete {
  padding: 7px 12px;
  background: transparent;
  color: var(--ic-red);
  border: 1px solid rgba(255,116,116,0.3);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 150ms ease, border-color 150ms ease;
}
.btn-delete:hover { background: rgba(255,116,116,0.08); border-color: var(--ic-red); }

/* 빈 패널 메시지 */
.edit-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* 캔버스 우상단 "+ 새 DB" 버튼 */
.cv-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
.btn-add-db {
  padding: 5px 11px;
  background: var(--ic-blue);
  color: var(--bg-base);
  border: 0;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: opacity 150ms ease;
}
.btn-add-db:hover { opacity: 0.88; }

/* "✨ 자동 배치" — 보조 톤 (테두리만, 클릭 시 관계 기반 자동 레이아웃) */
.btn-auto-layout {
  padding: 5px 10px;
  background: transparent;
  color: var(--text-tertiary);
  border: 1px solid var(--border-default);
  border-radius: 5px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}
.btn-auto-layout:hover {
  border-color: var(--ic-blue);
  color: var(--text-primary);
  background: rgba(122,171,247,0.06);
}

.pv-head-left {
  display: flex; align-items: center; gap: 10px;
}
.pv-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.pv-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.pv-viewrow {
  display: flex;
  gap: 2px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border-subtle);
  margin-top: 4px;
}
.vt {
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--text-tertiary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: color 0.1s;
  margin-bottom: -1px;
}
.vt:hover { color: var(--text-secondary); }
.vt.active { color: var(--text-primary); border-bottom-color: var(--text-primary); }
.vt-ico { font-size: 11px; opacity: 0.65; }

/* Notion table */
.tbl-wrap {
  padding: 6px 0 16px 22px;
  overflow-x: auto;
}
.ntbl {
  border-collapse: collapse;
  font-size: 13px;
  width: max-content;
  min-width: calc(100% - 40px);
}
.ntbl th {
  position: relative;
  text-align: left;
  font-weight: 400;
  color: var(--text-tertiary);
  font-size: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  white-space: nowrap;
  min-width: 120px;
  cursor: pointer;
  transition: background 0.12s;
}
.ntbl th:hover { background: var(--bg-surface); color: var(--text-secondary); }
.ntbl th.hl-rel { color: var(--rel-color); }
.ntbl th.hl-roll { color: var(--roll-color); }
.ntbl th:first-child { padding-left: 0; min-width: 180px; }
/* 고정폭 컬럼은 min/max 가 동일 — 넘치는 셀은 말줄임 */
.ntbl th.sized, .ntbl td.sized {
  min-width: var(--col-w) !important;
  max-width: var(--col-w);
  width: var(--col-w);
}
.ntbl td.sized { overflow: hidden; text-overflow: ellipsis; }
.ntbl td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  vertical-align: middle;
  white-space: nowrap;
  color: var(--text-primary);
}
.ntbl td:first-child { padding-left: 0; font-weight: 500; }
.ntbl tr:last-child td { border-bottom: none; }
.col-head { display: inline-flex; align-items: center; gap: 6px; }

/* 컬럼 리사이즈 핸들 — th 오른쪽 가장자리에 얇게 */
.th-resize {
  position: absolute;
  top: 0; right: -3px; bottom: 0;
  width: 7px;
  cursor: col-resize;
  user-select: none;
  z-index: 3;
  touch-action: none;
}
.th-resize::after {
  content: '';
  position: absolute;
  top: 14%; bottom: 14%;
  right: 3px;
  width: 2px;
  background: transparent;
  border-radius: 1px;
  transition: background 120ms ease;
}
.th-resize:hover::after,
.th-resize.active::after { background: var(--ic-blue); }
/* 드래그 중에는 커서 유지 */
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }
.col-ico {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  display: inline-block;
  width: 14px;
  text-align: center;
  letter-spacing: -0.03em;
}

.page-ref {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px 2px 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  font-size: 12.5px;
  border: 1px solid var(--border-subtle);
}
.page-ref-ico {
  width: 12px; height: 12px;
  border-radius: 2.5px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.page-ref-ico svg { width: 8px; height: 8px; }

.pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  margin-right: 4px;
}
.pill-gray { background: rgba(155,155,158,0.16); color: #C8C8CE; }
.pill-red { background: rgba(255,124,124,0.17); color: #FF9B9B; }
.pill-orange { background: rgba(255,158,89,0.17); color: #FFBA85; }
.pill-yellow { background: rgba(245,208,87,0.17); color: #F4D372; }
.pill-green { background: rgba(102,210,140,0.17); color: #88DDA6; }
.pill-blue { background: rgba(122,171,247,0.17); color: #9BBFF8; }
.pill-purple { background: rgba(180,158,224,0.17); color: #C4B2E8; }
.pill-pink { background: rgba(240,150,200,0.17); color: #F0ADCD; }
.pill-brown { background: rgba(180,138,106,0.17); color: #C9A58E; }

.roll-val {
  color: var(--roll-color);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.roll-val::before {
  content: '∑';
  color: var(--text-muted);
  margin-right: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
}
.rollup-source {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

/* rollup: percent_per_group 출력 — 완료% 숫자 + 가로 스택 바 + 그룹 레전드 */
.rollup-groups { display: inline-flex; flex-direction: column; gap: 4px; min-width: 160px; max-width: 240px; }
.rg-top { display: inline-flex; align-items: baseline; gap: 6px; font-size: 12px; }
.rg-done-pct { color: var(--roll-color); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.rg-total { color: var(--text-muted); font-size: 10.5px; font-family: var(--font-mono); }
.rg-bar {
  display: flex;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
}
.rg-seg { height: 100%; display: block; transition: width 180ms ease; }
.rg-legend { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; font-size: 10.5px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.rg-leg { display: inline-flex; align-items: center; gap: 4px; }
.rg-leg.is-done { color: var(--text-primary); font-weight: 500; }
.rg-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
/* swatch-* 색은 이미 정의돼 있어 .rg-seg / .rg-dot 에 그대로 적용 */
.rg-seg.swatch-gray   { background: rgba(155,155,158,0.6); }
.rg-seg.swatch-red    { background: rgba(255,116,116,0.7); }
.rg-seg.swatch-orange { background: rgba(255,158,89,0.7); }
.rg-seg.swatch-yellow { background: rgba(255,186,92,0.7); }
.rg-seg.swatch-green  { background: rgba(102,210,140,0.75); }
.rg-seg.swatch-teal   { background: rgba(102,205,205,0.7); }
.rg-seg.swatch-blue   { background: rgba(122,171,247,0.7); }
.rg-seg.swatch-purple { background: rgba(180,158,224,0.7); }
.rg-seg.swatch-pink   { background: rgba(240,150,200,0.7); }
.rg-seg.swatch-brown  { background: rgba(180,138,106,0.7); }
.rg-dot.swatch-gray   { background: rgba(155,155,158,0.85); }
.rg-dot.swatch-red    { background: rgba(255,116,116,0.95); }
.rg-dot.swatch-orange { background: rgba(255,158,89,0.95); }
.rg-dot.swatch-yellow { background: rgba(255,186,92,0.95); }
.rg-dot.swatch-green  { background: rgba(102,210,140,0.95); }
.rg-dot.swatch-teal   { background: rgba(102,205,205,0.95); }
.rg-dot.swatch-blue   { background: rgba(122,171,247,0.95); }
.rg-dot.swatch-purple { background: rgba(180,158,224,0.95); }
.rg-dot.swatch-pink   { background: rgba(240,150,200,0.95); }
.rg-dot.swatch-brown  { background: rgba(180,138,106,0.95); }

.cell-muted { color: var(--text-muted); }
.cell-num { font-variant-numeric: tabular-nums; }

.avatar {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 600;
  margin-right: 6px; vertical-align: middle;
  background: rgba(122,171,247,0.25);
  color: #A8C6FA;
}

.new-row {
  padding: 9px 10px;
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
}
.new-row:hover { color: var(--text-secondary); }

/* ── 인라인 셀 에디터 ── */
.cell-edit {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 3px;
  outline: none;
  transition: background 120ms ease;
  font-feature-settings: inherit;
}
.cell-edit::placeholder { color: var(--text-muted); }
.cell-edit:hover  { background: rgba(255,255,255,0.04); }
.cell-edit:focus  { background: rgba(255,255,255,0.08); }
.cell-edit-num    { font-variant-numeric: tabular-nums; }

.cell-sel {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  appearance: none;
  transition: background 120ms ease;
}
.cell-sel:hover { background: rgba(255,255,255,0.04); }
.cell-sel:focus { background: rgba(255,255,255,0.08); }
.cell-sel option { background: var(--bg-elevated); color: var(--text-primary); }

.cell-check {
  width: 14px; height: 14px;
  cursor: pointer;
  accent-color: var(--ic-blue);
}

/* 셀 안의 pill (select/status/multi) — 시각은 색 pill, 편집은 invisible input/select 가 위에 overlay */
.pill-cell {
  position: relative;
  display: block;
  min-height: 18px;
  width: 100%;
  padding: 1px 0;
  cursor: pointer;
}
.pill-cell-multi { cursor: pointer; min-height: 22px; }
.pill-cell-multi:hover { background: rgba(255,255,255,0.02); border-radius: 3px; }

/* multi 옵션 picker (popover) */
.multi-picker {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 260;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  min-width: 180px;
  max-height: 320px;
  overflow-y: auto;
}
.multi-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 120ms ease;
  user-select: none;
}
.multi-opt:hover { background: var(--bg-hover); }
.multi-opt-check {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ic-blue);
  font-size: 12px;
  flex-shrink: 0;
}
.multi-empty {
  padding: 16px 12px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.55;
}
.pill-cell .pill { pointer-events: none; }
.pill-cell .cell-muted { pointer-events: none; }
.pill-cell-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  padding: 0 4px;
  outline: none;
}
/* multi 셀: input 이 포커스되면 보이고 pill 들은 숨김 (텍스트 편집 상태) */
.pill-cell.editing .pill,
.pill-cell.editing .cell-muted { display: none; }
.pill-cell.editing .pill-cell-overlay {
  opacity: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--ic-blue);
  border-radius: 4px;
  cursor: text;
}

/* Property editor under the table */
.props {
  padding: 16px 22px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}
.props-title {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.btn-sort-props {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}
.btn-sort-props:hover {
  border-color: var(--ic-blue);
  color: var(--text-primary);
  background: rgba(122,171,247,0.06);
}
.props-list {
  display: flex; flex-direction: column; gap: 1px;
}
.prow {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background 0.1s;
}
.prow:hover { background: var(--bg-hover); }
.prow-ico {
  width: 22px; height: 22px;
  border-radius: 4px;
  background: var(--bg-elevated);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-mono);
  flex-shrink: 0;
  letter-spacing: -0.03em;
}
.prow-name { color: var(--text-primary); font-weight: 500; min-width: 140px; }
.prow-detail {
  color: var(--text-tertiary);
  font-size: 12px;
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.prow-arrow {
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.prow.is-rel .prow-ico { color: var(--rel-color); }
.prow.is-roll .prow-ico { color: var(--roll-color); }

/* ── 속성 행: 클릭 시 아코디언 확장 ── */
.prow {
  display: block !important;
  padding: 0 !important;
  background: transparent;
}
.prow:hover { background: transparent; }
.prow-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 150ms ease;
  position: relative;
}
.prow-summary:hover { background: var(--bg-hover); }
.prow.expanded .prow-summary {
  background: var(--bg-hover);
}

/* 드래그 핸들 (좌측, hover 시만 보임) */
.prow-handle {
  width: 14px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  cursor: grab;
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: opacity 120ms ease;
  user-select: none;
}
.prow-summary:hover .prow-handle { opacity: 1; }
.prow-handle:active { cursor: grabbing; }
.prow.dragging { opacity: 0.4; }
.prow.drag-over-top    { box-shadow: inset 0 2px 0 0 var(--ic-blue); }
.prow.drag-over-bottom { box-shadow: inset 0 -2px 0 0 var(--ic-blue); }
.prow-summary .prow-ico {
  width: 22px; height: 22px;
  border-radius: 4px;
  background: var(--bg-elevated);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-mono);
  flex-shrink: 0;
  letter-spacing: -0.03em;
}
.prow.is-rel  .prow-summary .prow-ico { color: var(--pair-color, var(--rel-color)); }
.prow.is-roll .prow-summary .prow-ico { color: var(--pair-color, var(--roll-color)); }
.prow-summary .prow-name { color: var(--text-primary); font-weight: 500; min-width: 100px; }
.prow-summary .prow-detail {
  color: var(--text-tertiary);
  font-size: 12px;
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

/* ── 확장된 폼 ── */
.prow-form {
  margin: 6px 4px 10px;
  padding: 12px 12px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prow-form-field { display: flex; flex-direction: column; gap: 4px; }
.prow-form-field .edit-label { font-size: 10px; }
.prow-input, .prow-select {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 12.5px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 150ms ease;
}
.prow-input:focus, .prow-select:focus { border-color: var(--ic-blue); }
.prow-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L2 4h8z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 10px; padding-right: 24px; }
.prow-form-actions {
  display: flex; justify-content: flex-end;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}
.btn-prop-delete {
  padding: 5px 10px;
  background: transparent;
  color: var(--ic-red);
  border: 1px solid rgba(255,116,116,0.25);
  border-radius: 5px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 150ms ease;
}
.btn-prop-delete:hover { background: rgba(255,116,116,0.08); }

/* ── + 속성 추가 버튼 ── */
.btn-add-prop {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  background: transparent;
  color: var(--text-tertiary);
  border: 1px dashed var(--border-default);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  text-align: left;
  transition: all 150ms ease;
}
.btn-add-prop:hover { border-color: var(--border-strong); color: var(--text-secondary); background: rgba(255,255,255,0.02); }

/* relation 타겟 미설정 경고 색 */
.prow-warn { color: var(--ic-yellow); font-size: 11.5px; }
.prow-hint { color: var(--text-muted); font-size: 11px; margin-top: 4px; display: inline-block; }
.prow-formula {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  min-height: 64px;
  resize: vertical;
  /* pre 는 가로 스크롤이 생겨서 긴 수식이 가려짐 → pre-wrap 으로 줄바꿈 허용.
     공백/탭/개행은 그대로 보존. */
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 9px 10px;
  letter-spacing: 0;
  tab-size: 2;
}
.prow-formula.has-unresolved {
  border-color: rgba(255,186,92,0.4);
  background: rgba(255,186,92,0.03);
}
.formula-warn {
  margin-top: 6px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  background: rgba(255,186,92,0.06);
  border: 1px solid rgba(255,186,92,0.28);
  border-radius: 6px;
}
.formula-warn code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(255,255,255,0.05);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-primary);
}

/* ── 수식 하이라이트 미리보기 (textarea 아래 읽기 전용 <pre>) ── */
.prow-formula-preview {
  margin: 6px 0 0 0;
  padding: 9px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 20px;
  user-select: text;
}
.prow-formula-preview:empty::before {
  content: '수식을 입력하면 여기에 prop("이름") 참조가 하이라이트됩니다';
  color: var(--text-muted);
  font-style: italic;
}
/* prop("…") pill — relation/rollup 은 타겟 DB 의 색(.ic-*-bg) 을 그대로 상속,
   그 외 타입 또는 cross-DB 참조는 fx-prop-plain 중립 그레이. */
.prow-formula-preview .fx-prop {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
  font-weight: 500;
}
.prow-formula-preview .fx-prop-plain {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border-color: rgba(255,255,255,0.12);
}
/* 해석 못한 [외부참조:…] — 빨강 경고 */
.prow-formula-preview .fx-prop-bad {
  background: rgba(255,116,116,0.14);
  color: #FFB0B0;
  border-color: rgba(255,116,116,0.32);
}

/* ── 옵션 편집기 (select/multi/status) ── */
.opt-list { display: flex; flex-direction: column; gap: 4px; padding: 2px 0; }
.opt-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  border-radius: 5px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
}
.opt-color-btn {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 0;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.opt-color-btn.swatch-gray   { background: rgba(155,155,158,0.45); }
.opt-color-btn.swatch-red    { background: rgba(255,116,116,0.45); }
.opt-color-btn.swatch-orange { background: rgba(255,158,89,0.45); }
.opt-color-btn.swatch-yellow { background: rgba(255,186,92,0.45); }
.opt-color-btn.swatch-green  { background: rgba(102,210,140,0.45); }
.opt-color-btn.swatch-blue   { background: rgba(122,171,247,0.45); }
.opt-color-btn.swatch-purple { background: rgba(180,158,224,0.45); }
.opt-color-btn.swatch-pink   { background: rgba(240,150,200,0.45); }
.opt-color-btn.swatch-brown  { background: rgba(180,138,106,0.45); }
.opt-name {
  flex: 1; min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  padding: 2px 4px;
  outline: none;
  border-radius: 3px;
}
.opt-name:focus { background: rgba(255,255,255,0.04); }
.opt-delete {
  width: 20px; height: 20px;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  border-radius: 4px;
  flex-shrink: 0;
}
.opt-delete:hover { color: var(--ic-red); background: rgba(255,116,116,0.08); }
.btn-add-opt {
  align-self: flex-start;
  margin-top: 2px;
  background: transparent;
  border: 1px dashed var(--border-default);
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 11.5px;
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 150ms ease;
}
.btn-add-opt:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: rgba(255,255,255,0.02);
}

/* 색 popover (옵션의 색 선택 팝오버) */
.opt-color-popover {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 7px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(5, 22px);
  gap: 6px;
  z-index: 250;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.opt-color-popover .color-dot {
  width: 22px; height: 22px;
  border-radius: 5px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 120ms ease;
}
.opt-color-popover .color-dot:hover { transform: scale(1.1); }
.opt-color-popover .color-dot.active { border-color: var(--text-primary); }
.opt-color-popover .color-dot.swatch-gray   { background: rgba(155,155,158,0.5); }
.opt-color-popover .color-dot.swatch-red    { background: rgba(255,116,116,0.5); }
.opt-color-popover .color-dot.swatch-orange { background: rgba(255,158,89,0.5); }
.opt-color-popover .color-dot.swatch-yellow { background: rgba(255,186,92,0.5); }
.opt-color-popover .color-dot.swatch-green  { background: rgba(102,210,140,0.5); }
.opt-color-popover .color-dot.swatch-blue   { background: rgba(122,171,247,0.5); }
.opt-color-popover .color-dot.swatch-purple { background: rgba(180,158,224,0.5); }
.opt-color-popover .color-dot.swatch-pink   { background: rgba(240,150,200,0.5); }
.opt-color-popover .color-dot.swatch-brown  { background: rgba(180,138,106,0.5); }

/* ===================== MODAL ===================== */
.modal-bg {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2147483646 !important;   /* 최상위 — auth-gate / 다른 어떤 것보다 위에 */
  padding: 20px;
}
.modal-bg.show { display: flex !important; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  width: 640px;
  max-width: 100%;
  max-height: 85vh;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal.modal-wide { width: 820px; }

/* 템플릿 프리뷰 모달 */
.tp-prev-head { display: flex; align-items: flex-start; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border-subtle); }
.tp-prev-head-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tp-prev-title { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.tp-prev-desc { color: var(--text-secondary); font-size: 13px; }
.tp-prev-stats { display: inline-flex; gap: 14px; font-size: 11.5px; color: var(--text-tertiary); font-family: var(--font-mono); margin-top: 6px; }
.tp-prev-stats span strong { color: var(--text-primary); font-weight: 500; font-family: var(--font-sans); margin-right: 3px; }
.tp-prev-body { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; max-height: 55vh; padding: 2px 0; }
.tp-prev-db {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg-elevated);
}
.tp-prev-db-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.tp-prev-db-name { font-weight: 500; font-size: 13.5px; }
.tp-prev-db-meta { margin-left: auto; color: var(--text-muted); font-size: 10.5px; font-family: var(--font-mono); }
.tp-prev-db-desc { color: var(--text-tertiary); font-size: 12px; line-height: 1.5; margin-bottom: 8px; }
.tp-prev-props { display: flex; flex-wrap: wrap; gap: 5px 6px; }
.tp-prev-prop {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.tp-prev-prop .tp-prev-prop-ico { color: var(--text-muted); font-family: var(--font-mono); font-size: 10.5px; min-width: 10px; text-align: center; }
.tp-prev-prop.is-rel  { color: var(--rel-color); border-color: rgba(110,176,230,0.25); background: rgba(110,176,230,0.08); }
.tp-prev-prop.is-rel  .tp-prev-prop-ico { color: var(--rel-color); }
.tp-prev-prop.is-roll { color: var(--roll-color); border-color: rgba(180,158,224,0.25); background: rgba(180,158,224,0.08); }
.tp-prev-prop.is-roll .tp-prev-prop-ico { color: var(--roll-color); }
.tp-prev-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 10px 12px;
  border: 1px dashed var(--border-default);
  border-radius: 6px;
  line-height: 1.5;
}

/* 템플릿 구조도 썸네일 — 템플릿 x/y 좌표에 카드를 배치하고 CSS transform: scale 로 축소. */
.tpn-wrap {
  position: relative;
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-base);
  overflow: hidden;
  padding: 0;
}
.tpn-scale {
  position: relative;
  transform-origin: 0 0;
}
.tpn-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.tpn-card {
  position: absolute;
  width: 186px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 9px;
  overflow: hidden;
  z-index: 2;
}
.tpn-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-hover);
}
.tpn-card-name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tpn-card-badge {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.tpn-card-props { padding: 4px 0 6px; }
.tpn-prop {
  display: flex; align-items: center; gap: 9px;
  padding: 3.5px 11px;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.tpn-prop-ico {
  width: 10px;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-mono);
  text-align: center;
  flex-shrink: 0;
}
.tpn-prop-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpn-prop.is-rel  { color: var(--rel-color); }
.tpn-prop.is-rel  .tpn-prop-ico { color: var(--rel-color); opacity: 0.65; }
.tpn-prop.is-roll { color: var(--roll-color); }
.tpn-prop.is-roll .tpn-prop-ico { color: var(--roll-color); opacity: 0.65; }
.tpn-prop-more {
  padding: 3.5px 11px;
  font-size: 10.5px;
  color: var(--text-muted);
}

/* 템플릿 미리보기 우측 드로어 */
.tpl-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(720px, 92vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  box-shadow: -16px 0 48px rgba(0,0,0,0.5);
  z-index: 90;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.tpl-drawer.open { transform: translateX(0); pointer-events: auto; }
.tpl-drawer-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.tpl-drawer-head-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tpl-drawer-title { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; color: var(--text-primary); }
.tpl-drawer-desc  { font-size: 13px; color: var(--text-secondary); }
.tpl-drawer-stats { display: inline-flex; gap: 14px; font-size: 11.5px; color: var(--text-tertiary); font-family: var(--font-mono); margin-top: 6px; }
.tpl-drawer-stats span strong { color: var(--text-primary); font-weight: 500; font-family: var(--font-sans); margin-right: 3px; }
.tpl-drawer-close {
  width: 28px; height: 28px;
  border: 0; background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 22px; line-height: 1;
  border-radius: 6px;
  flex-shrink: 0;
}
.tpl-drawer-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* 줌·팬 영역 — 스크롤 가능한 뷰포트 안에 크기가 유동적인 thumbnail wrap 을 둠 */
.tpl-drawer-zoom {
  flex: 1;
  overflow: auto;
  background: var(--bg-base);
  position: relative;
  cursor: grab;
  touch-action: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border-default) transparent;
}
.tpl-drawer-zoom.grabbing { cursor: grabbing; }
.tpl-drawer-zoom::-webkit-scrollbar { width: 8px; height: 8px; }
.tpl-drawer-zoom::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 4px; }
.tpl-drawer-zoom .tpn-wrap {
  /* 드로어 안에서는 wrap 이 스크롤 영역에 맞게 동적으로 크기 지정 (inline style 로) */
  border: 0;
  background: transparent;
  margin: 24px;
}
.tpl-drawer-zoom .tpn-scale {
  transform-origin: 0 0;
  transition: none;
}

.tpl-drawer-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg-surface);
}
.tpl-drawer-hint-inline {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}
.tpl-drawer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tpl-drawer-zoompct {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  padding: 5px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  margin-right: auto;
  cursor: pointer;
  user-select: none;
}
.tpl-drawer-zoompct:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-head {
  display: flex; align-items: center; gap: 10px;
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.modal-close {
  margin-left: auto;
  width: 28px; height: 28px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.modal-note {
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(122,171,247,0.05);
  border: 1px solid rgba(122,171,247,0.18);
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.65;
}
.modal-note strong { color: var(--text-primary); font-weight: 500; }
.modal-note a { color: var(--ic-blue); text-decoration: none; border-bottom: 1px dotted var(--ic-blue); }
.modal-note a:hover { border-bottom-style: solid; }
.modal-note code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  color: var(--text-primary);
}
.modal-note-head {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13.5px;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.modal-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
}
.modal-steps li { margin-bottom: 4px; }
.modal-steps li:last-child { margin-bottom: 0; }
.modal-preview-wrap { margin-top: 4px; }
.modal-json {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  max-height: 320px;
  overflow: auto;
  white-space: pre;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

/* Modal form inputs (token, page id) */
.field-label {
  font-size: 13px;
  color: var(--text-primary);
  letter-spacing: -0.005em;
  font-weight: 500;
  margin-bottom: 6px;
  display: block;
}
.field-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.12s;
}
.field-input:focus { border-color: var(--ic-blue); }
.field-input::placeholder { color: var(--text-muted); font-family: var(--font-mono); }
.field-hint { font-size: 11.5px; color: var(--text-tertiary); margin-top: 6px; line-height: 1.55; }
.field-hint a { color: var(--ic-blue); text-decoration: none; }
.field-hint a:hover { text-decoration: underline; }
.field-group { display: flex; flex-direction: column; }
.modal-result-list {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px;
}
.modal-result-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
}
.modal-result-row a {
  margin-left: auto;
  color: var(--ic-blue);
  text-decoration: none;
  font-size: 12px;
}
.modal-result-row a:hover { text-decoration: underline; }
details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 6px 0;
  user-select: none;
}
details summary:hover { color: var(--text-secondary); }
details[open] summary { margin-bottom: 6px; }

/* ===================== AUTH GATE ===================== */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  overflow: auto;
}
.auth-gate.hidden { display: none; }
.auth-card {
  width: 380px;
  max-width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.auth-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600; letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.auth-headline {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-top: 4px;
}
.auth-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.55;
  margin-bottom: 4px;
}
/* 구글 로그인 버튼 — 전통적 OAuth 리다이렉트용 (GIS 스크립트 미사용) */
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 44px;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
  letter-spacing: -0.01em;
}
.btn-google:hover {
  background: #f7f8f8;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  border-color: #d1d5db;
}
.btn-google:active { background: #eceef0; }
.btn-google-ico { width: 18px; height: 18px; flex-shrink: 0; }
.auth-google-note {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 8px 10px;
  border: 1px dashed var(--border-default);
  border-radius: 6px;
}
.auth-google-note code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
}
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 4px 0;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default);
}
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-status:empty { display: none; }
.auth-status {
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255,116,116,0.08);
  color: var(--ic-red);
  border: 1px solid rgba(255,116,116,0.2);
  line-height: 1.5;
}
.auth-status.info {
  background: rgba(122,171,247,0.06);
  color: var(--text-secondary);
  border-color: rgba(122,171,247,0.2);
}
.auth-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

.auth-forgot-row { margin-top: 14px; text-align: center; }
.auth-forgot-link {
  background: transparent;
  border: 0;
  color: var(--ic-blue);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  text-decoration: underline;
  text-decoration-color: rgba(122,171,247,0.45);
  text-underline-offset: 3px;
  opacity: 0.9;
  transition: opacity 0.15s, background 0.15s;
}
.auth-forgot-link:hover {
  opacity: 1;
  background: rgba(122,171,247,0.06);
  text-decoration-color: var(--ic-blue);
}

/* 미인증 사용자 배너 — 화면 하단 고정 */
.verify-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  background: rgba(255,186,92,0.1);
  border: 1px solid rgba(255,186,92,0.3);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  font-size: 12.5px;
  color: var(--text-secondary);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.verify-banner-msg strong { color: var(--text-primary); }
.verify-banner-resend {
  background: rgba(122,171,247,0.15);
  border: 1px solid rgba(122,171,247,0.35);
  color: var(--ic-blue);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
}
.verify-banner-resend:hover { background: rgba(122,171,247,0.25); }
.verify-banner-resend:disabled { opacity: 0.5; cursor: default; }
.verify-banner-close {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
}
.verify-banner-close:hover { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

/* ===================== SETTINGS / PRICING PAGES ===================== */
.settings-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 32px 96px;
  overflow-y: auto;
  height: 100%;
  width: 100%;
}
.settings-head { margin-bottom: 36px; }
.settings-title { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; color: var(--text-primary); }
.settings-sub { color: var(--text-secondary); font-size: 14px; }

.settings-section { margin-bottom: 36px; }
.settings-section-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 4px 20px;
}
.settings-section.settings-danger .settings-card { border-color: rgba(255,116,116,0.25); }

.settings-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row-block { display: block; }
.settings-row-label {
  flex: 0 0 160px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.settings-row-block .settings-row-label { margin-bottom: 8px; }
.settings-row-value { flex: 1; min-width: 0; color: var(--text-secondary); font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.settings-row-block .settings-row-value { display: block; }
.settings-row-help { color: var(--text-muted); font-size: 11.5px; margin-top: 6px; }

.settings-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  border: 1px solid transparent;
}
.settings-badge-ok { color: var(--ic-green); background: rgba(102,210,140,0.1); border-color: rgba(102,210,140,0.3); }
.settings-badge-warn { color: var(--ic-yellow); background: rgba(255,186,92,0.1); border-color: rgba(255,186,92,0.3); }

.settings-link-btn {
  background: transparent;
  border: 0;
  color: var(--ic-blue);
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  text-decoration: underline;
  text-decoration-color: rgba(122,171,247,0.4);
}
.settings-link-btn:hover { background: rgba(122,171,247,0.08); }

.settings-pwform { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.settings-pwform .field-input { flex: 1; min-width: 180px; }
.settings-status { font-size: 11.5px; margin-top: 8px; }

.settings-lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  overflow: hidden;
}
.settings-lang-btn {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
  border-right: 1px solid var(--border-default);
}
.settings-lang-btn:last-child { border-right: 0; }
.settings-lang-btn.active { background: var(--bg-active); color: var(--text-primary); }
.settings-lang-btn:hover:not(.active) { background: var(--bg-hover); }

.settings-plan-summary { display: flex; flex-direction: column; gap: 14px; padding: 12px 0; }
.settings-plan-name { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.settings-plan-usage { font-size: 12px; color: var(--text-secondary); }
.settings-plan-usage-label { margin-bottom: 6px; }
.settings-plan-usage-bar { height: 6px; background: var(--bg-active); border-radius: 3px; overflow: hidden; }
.settings-plan-usage-fill { height: 100%; background: var(--ic-blue); transition: width 0.3s; }

.settings-danger-btn { color: var(--ic-red); border-color: rgba(255,116,116,0.3); }
.settings-danger-btn:hover { background: rgba(255,116,116,0.08); }

/* ── Pricing ── */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 48px;
}
.plan-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.plan-card-featured { border-color: rgba(180,158,224,0.4); background: linear-gradient(180deg, rgba(180,158,224,0.05), transparent); }
.plan-card-active   { border-color: var(--ic-blue); }
.plan-card-current {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  background: var(--ic-blue);
  color: #fff;
  border-radius: 4px;
}
.plan-card-name { font-size: 22px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.plan-card-desc { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 18px; }
.plan-card-price { display: flex; align-items: baseline; gap: 4px; margin-bottom: 24px; }
.plan-card-price-amount { font-size: 30px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.plan-card-price-unit { color: var(--text-tertiary); font-size: 13px; }
.plan-card-feats {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.plan-card-feats li {
  font-size: 13px;
  color: var(--text-secondary);
  position: relative;
  padding-left: 20px;
}
.plan-card-feats li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--ic-green);
  font-weight: 700;
}
.plan-card-cta {
  width: 100%;
  padding: 10px 16px;
  background: var(--ic-blue);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.plan-card-cta:disabled { opacity: 0.55; cursor: not-allowed; background: var(--bg-active); color: var(--text-secondary); }
.plan-card-cta-current { background: rgba(122,171,247,0.15); color: var(--ic-blue); border: 1px solid rgba(122,171,247,0.3); cursor: default; opacity: 1; }
.plan-card-cta-note { font-size: 11px; color: var(--text-tertiary); text-align: center; margin-top: 8px; }

/* 템플릿 카드 — Pro 배지 / 잠긴 상태 */
.tpl-card { position: relative; }
.tpl-card-pro-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  background: rgba(255,186,92,0.18);
  color: var(--ic-yellow);
  border: 1px solid rgba(255,186,92,0.35);
  border-radius: 4px;
  z-index: 1;
}
.tpl-card-pro-badge.tpl-card-pro-locked {
  background: rgba(255,255,255,0.04);
  color: var(--text-tertiary);
  border-color: var(--border-default);
}
.tpl-card.tpl-card-locked {
  opacity: 0.7;
  background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent);
}
.tpl-card.tpl-card-locked .tpl-card-title,
.tpl-card.tpl-card-locked .tpl-card-desc {
  color: var(--text-tertiary);
}
.tpl-card-btn-locked {
  background: rgba(255,255,255,0.04) !important;
  color: var(--text-tertiary) !important;
  border-color: var(--border-default) !important;
  cursor: pointer;     /* 클릭 가능 — 업그레이드 모달 노출 */
}
.tpl-card-btn-locked:hover { background: rgba(255,186,92,0.06) !important; color: var(--ic-yellow) !important; }

/* 미리보기 드로어 — Pro 잠금 상태 */
.tpl-drawer.tpl-drawer-locked .tpn-wrap,
.tpl-drawer.tpl-drawer-locked .tpn-scale {
  filter: blur(8px) saturate(0.6);
  pointer-events: none;
  user-select: none;
}
.tpl-drawer.tpl-drawer-locked .tpl-drawer-zoom {
  position: relative;
  overflow: hidden;
}
.tpl-drawer.tpl-drawer-locked .tpl-drawer-head {
  opacity: 0.85;
}
.tpl-drawer-lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(11,11,13,0.55), rgba(11,11,13,0.75));
  backdrop-filter: blur(2px);
  z-index: 10;
}
.tpl-drawer-lock-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255,186,92,0.35);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.tpl-drawer-lock-ico {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.8;
}
.tpl-drawer-lock-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ic-yellow);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.tpl-drawer-lock-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 18px;
}
.tpl-drawer-lock-card .tb-btn.primary {
  padding: 8px 20px;
  font-size: 13px;
}

.pricing-faq { margin-top: 36px; }
.pricing-faq-item {
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 0;
}
.pricing-faq-item summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  list-style: none;
  position: relative;
  padding-right: 24px;
}
.pricing-faq-item summary::-webkit-details-marker { display: none; }
.pricing-faq-item summary::after {
  content: '+';
  position: absolute;
  right: 0;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 400;
  transition: transform 0.2s;
}
.pricing-faq-item[open] summary::after { content: '−'; }
.pricing-faq-item div { color: var(--text-secondary); font-size: 12.5px; line-height: 1.7; margin-top: 8px; padding-right: 24px; }
.pricing-faq-item a { color: var(--ic-blue); }

@media (max-width: 720px) {
  .pricing-grid { grid-template-columns: 1fr; }
  .settings-row { flex-direction: column; align-items: flex-start; }
  .settings-row-label { flex: 0 0 auto; }
}

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-primary);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ic-green);
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1200px) {
  .secondary { width: 200px; }
  .gallery { padding: 28px 32px 48px; }
  .edit-panel { --panel-w: 360px; }
}
