/* ═══════════════════════════════════════════════════════════════════════════
   Phase 4 — Dashboard (= Menu) v5 Cosmic Glassmorphism
   mockup css/01~06 기반, --v5-* 변수 사용
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 대시보드 셸 ── */
.dash-shell {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

/* ── 사이드바 ── */
.dash-side {
  width: 220px;
  background: var(--v5-surface-solid);
  border-right: 1px solid var(--v5-border);
  padding: .85rem .6rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
  transition: width .35s cubic-bezier(.4,0,.2,1), padding .35s;
}
.dash-side-sec {
  font-size: .55rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--v5-text-muted);
  padding: .5rem .65rem .35rem;
}
.dash-si {
  padding: .5rem .7rem; border-radius: 10px; font-size: .77rem;
  color: var(--v5-text-sec); cursor: pointer;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  font-weight: 450; display: flex; align-items: center; gap: .6rem;
  position: relative; overflow: hidden;
}
.dash-si .ic { width: 16px; height: 16px; display: flex; align-items: center;
  justify-content: center; opacity: .65; flex-shrink: 0; font-size: .85rem; }
.dash-si:hover { background: var(--v5-surface-hover); color: var(--v5-text);
  transform: translateX(2px); }
.dash-si.on {
  background: linear-gradient(135deg, rgba(var(--v5-primary-rgb),.12), rgba(var(--v5-primary-rgb),.05));
  color: var(--v5-primary); font-weight: 600;
  border: 1px solid rgba(var(--v5-primary-rgb),.15); box-shadow: var(--v5-glow-sm);
}
.dark .dash-si.on {
  background: linear-gradient(135deg, rgba(var(--v5-primary-rgb),.14), rgba(var(--v5-primary-rgb),.05));
  border-color: rgba(var(--v5-primary-rgb),.15);
}
.dash-si::before { content: ''; position: absolute; left: 0; top: 0; width: 3px;
  height: 100%; background: var(--v5-primary); border-radius: 0 2px 2px 0;
  transform: scaleY(0); transition: transform .2s cubic-bezier(.4,0,.2,1); }
.dash-si.on::before { transform: scaleY(1); }

/* 사이드바 호버 액션 (rename/delete) */
.dash-si-actions { margin-left: auto; display: flex; gap: .15rem;
  opacity: 0; transition: opacity .15s; }
.dash-si:hover .dash-si-actions { opacity: 1; }
.dash-si-act { width: 18px; height: 18px; border-radius: 5px; border: none;
  background: transparent; color: var(--v5-text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; font-size: .55rem; }
.dash-si-act:hover { background: var(--v5-surface-hover); color: var(--v5-primary); }
.dash-si-act.danger:hover { background: rgba(var(--v5-red-rgb),.12); color: var(--v5-red); }

/* 새 대시보드 추가 버튼 */
.dash-add-btn {
  display: flex; align-items: center; gap: .5rem; padding: .45rem .7rem;
  border-radius: 10px; border: 1px dashed var(--v5-glass-border);
  background: transparent; color: var(--v5-text-muted); cursor: pointer;
  font-size: .7rem; font-weight: 600; font-family: inherit;
  transition: all .2s; margin: .3rem 0;
}
.dash-add-btn:hover { border-color: var(--v5-primary); color: var(--v5-primary);
  background: rgba(var(--v5-primary-rgb),.04); }

/* ── 콘텐츠 영역 ── */
.dash-content {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── 캔버스 툴바 ── */
.dash-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.25rem; background: var(--v5-surface-solid);
  border-bottom: 1px solid var(--v5-border); flex-shrink: 0;
}
.dash-toolbar-l { display: flex; align-items: center; gap: .75rem; }
.dash-cv-title { font-size: .95rem; font-weight: 700; color: var(--v5-text);
  letter-spacing: -.01em; }
.dash-cv-meta {
  font-size: .6rem; color: var(--v5-text-muted); padding: .2rem .55rem;
  border-radius: 999px; background: var(--v5-surface);
  border: 1px solid var(--v5-glass-border);
}
.dash-toolbar-r { display: flex; align-items: center; gap: .5rem; }
.dash-btn {
  display: flex; align-items: center; gap: .4rem; padding: .42rem .8rem;
  border-radius: 10px; border: 1px solid var(--v5-border);
  background: var(--v5-surface-solid); color: var(--v5-text-sec);
  font-size: .68rem; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all .2s;
}
.dash-btn:hover { border-color: var(--v5-primary); color: var(--v5-primary);
  box-shadow: var(--v5-glow-sm); }
.dash-btn.primary {
  background: linear-gradient(135deg, var(--v5-primary), var(--v5-primary-light));
  color: white; border-color: transparent; box-shadow: var(--v5-glow-sm);
}
.dash-btn.primary:hover { transform: translateY(-1px); box-shadow: var(--v5-glow-md); }
.dash-btn.on {
  background: linear-gradient(135deg, var(--v5-primary), var(--v5-primary-light));
  color: white; border-color: transparent; box-shadow: var(--v5-glow-sm);
}

/* ── 캔버스 ── */
.dash-canvas {
  display: block;
  align-self: stretch;
  flex: 1 1 auto;
  width: 100%;
  min-width: 100%;
  height: 100%;
  position: relative;
  padding: 0;
  min-height: 0;
  overflow: hidden;
  background-color: var(--v5-bg);
  background-image: radial-gradient(circle at 0.5px 0.5px, var(--v5-border) 0.5px, transparent 0);
  background-size: 20px 20px;
  transition: background-color .3s var(--v5-ease-move), box-shadow .3s var(--v5-ease-move);
}
/* edit / control 모드 시각 효과는 control-mode.css 에서 관리 */

/* ── 카드 ── */
/* ★ wrapper(position:absolute)가 위치 잡고, .dash-card는 wrapper 채움 */
.dash-card {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--v5-surface-solid);
  border: 1px solid var(--v5-border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow .25s, border-color .25s;
  z-index: 10;
}
.dark .dash-card {
  background: var(--v5-surface-solid);
  border-color: var(--v5-border);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.dark .dash-card { box-shadow: 0 2px 8px rgba(0,0,0,0.24); }
.dash-card:hover { border-color: var(--v5-border); box-shadow: inherit; }
.dash-canvas.edit-mode .dash-card {
  cursor: move;
  border-style: solid;
  border-color: rgba(var(--v5-primary-rgb),.3);
}
.dash-canvas.edit-mode .dash-card-head,
.dash-canvas.edit-mode .dash-card-body {
  cursor: move;
  user-select: none;
}
.dash-canvas.edit-mode .dash-card-body > * {
  pointer-events: none;
}
.dash-card.dragging {
  box-shadow: 0 0 0 1px rgba(var(--v5-primary-rgb),.35);
  border-color: var(--v5-primary); z-index: 50;
}
.dash-card.resizing {
  box-shadow: 0 0 0 1px rgba(var(--v5-cyan-rgb),.38);
  border-color: var(--v5-cyan); z-index: 50;
}

/* 전체화면 — 카드 헤더의 Maximize2 토글 시 viewport 전체로 확장.
   부모 .v5-body 가 overflow:hidden 으로 stacking context 를 만들기 때문에
   DashboardCard 가 createPortal 로 document.body 에 마운트하여 진짜 viewport 기준 fixed. */
.dash-card.fullscreen {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  z-index: 1000;
  border-radius: 0;
  border: none;
  box-shadow: 0 0 0 1px var(--v5-border), 0 -4px 24px rgba(0,0,0,.06);
  cursor: default !important;
  transform-origin: 50% 50%;
  animation: dash-card-fs-in .26s cubic-bezier(.16,1,.3,1);
}
.dash-card.fullscreen .dash-resize-handle { display: none !important; }
.dash-card.fullscreen .dash-card-head {
  animation: dash-card-fs-head-in .35s cubic-bezier(.16,1,.3,1) both;
  animation-delay: .04s;
}
.dash-card.fullscreen .dash-card-body {
  animation: dash-card-fs-body-in .4s cubic-bezier(.16,1,.3,1) both;
  animation-delay: .08s;
}

@keyframes dash-card-fs-in {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes dash-card-fs-head-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dash-card-fs-body-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Exit 애니메이션 — closing flag 가 220ms 동안 유지되는 동안 fade-out + scale-down 후 unmount */
.dash-card.fullscreen.closing {
  animation: dash-card-fs-out .22s cubic-bezier(.4,0,1,1) forwards;
}
.dash-card.fullscreen.closing .dash-card-head,
.dash-card.fullscreen.closing .dash-card-body {
  animation: none;
}
@keyframes dash-card-fs-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(.96); }
}

/* 카드 헤더 */
.dash-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--v5-border-subtle); flex-shrink: 0;
  background: transparent;
}
.dash-card-head-l { display: flex; align-items: center; gap: .55rem; }
.dash-card-icon {
  width: 24px; height: 24px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center; font-size: .85rem;
  background: linear-gradient(135deg, rgba(var(--v5-primary-rgb),.15), rgba(var(--v5-cyan-rgb),.1));
  border: 1px solid rgba(var(--v5-primary-rgb),.18);
}
.dash-card-title { font-size: .78rem; font-weight: 700; color: var(--v5-text);
  letter-spacing: -.01em; }
.dash-card-bdg {
  font-size: .5rem; font-weight: 700; color: var(--v5-primary);
  padding: .1rem .4rem; border-radius: 999px;
  background: rgba(var(--v5-primary-rgb),.08); border: 1px solid rgba(var(--v5-primary-rgb),.18);
  text-transform: uppercase; letter-spacing: .05em;
}
.dash-card-head-r { display: flex; align-items: center; gap: .3rem; }
.dash-card-btn {
  width: 22px; height: 22px; border-radius: 6px; border: none;
  background: transparent; color: var(--v5-text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.dash-card-btn:hover { background: var(--v5-surface-hover); color: var(--v5-primary); }
.dash-card-btn.danger:hover { background: rgba(var(--v5-red-rgb),.12); color: var(--v5-red); }

/* 카드 본문 — container query 활성화 */
.dash-card-body {
  flex: 1;
  overflow: auto;
  padding: .5rem;
  container-type: inline-size;
  container-name: card;
}

/* 에러/로딩 상태 */
.dash-card-error {
  padding: 2rem;
  text-align: center;
  color: var(--v5-red);
  font-size: .7rem;
}
.dash-card-loading {
  padding: 2rem;
  text-align: center;
  color: var(--v5-text-muted);
  font-size: .7rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Template grid 기반 컴포넌트 렌더 (business kind)
   ═══════════════════════════════════════════════════════════════════════════ */

.dash-card-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 12), minmax(0, 1fr));
  gap: var(--grid-gap, .5rem);
  width: 100%;
  align-content: start;
}

/* 각 컴포넌트 슬롯 — grid item min-width:0 은 12열 비율 유지의 핵심 */
.dash-card-grid > .tpl-component {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  grid-column: var(--col) / span var(--col-span);
  grid-row: var(--row) / span var(--row-span);
}

/* ── 반응형 — 카드 너비 기준 @container ── */
/* 각 breakpoint에서 col / row 를 모두 오버라이드해야 responsive.row도 적용됨. */
@container card (max-width: 520px) {
  .dash-card-grid { gap: var(--grid-gap-narrow, .35rem); }
  .dash-card-grid > .tpl-component {
    grid-column: var(--col-narrow) / span var(--col-span-narrow);
    grid-row: var(--row-narrow) / span var(--row-span-narrow);
  }
}

@container card (min-width: 520.01px) and (max-width: 900px) {
  .dash-card-grid { gap: var(--grid-gap-normal, .45rem); }
  .dash-card-grid > .tpl-component {
    grid-column: var(--col-normal) / span var(--col-span-normal);
    grid-row: var(--row-normal) / span var(--row-span-normal);
  }
}

@container card (min-width: 900.01px) {
  .dash-card-grid { gap: var(--grid-gap-wide, .55rem); }
  .dash-card-grid > .tpl-component {
    grid-column: var(--col-wide) / span var(--col-span-wide);
    grid-row: var(--row-wide) / span var(--row-span-wide);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Canvas kind 자유배치 렌더
   ═══════════════════════════════════════════════════════════════════════════ */

.dash-card-canvas-wrapper {
  width: 100%;
  height: 100%;
  overflow: auto;
}
.dash-card-canvas {
  position: relative;
  width: 100%;
  min-height: 100%;
}
.dash-card-canvas > .tpl-component {
  position: absolute;
  overflow: hidden;
}

/* 리사이즈 핸들 — 8방향 (edit mode 에서만 표시)
   ★ DashboardCard 가 <div className="dash-resize-handle {dir}" data-resize="{dir}"/> 8개 렌더
*/
.dash-resize-handle {
  position: absolute; display: none; z-index: 20;
  color: var(--v5-text-muted); opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.dash-canvas.edit-mode .dash-resize-handle { display: block; }
.dash-canvas.edit-mode [data-card-id]:hover .dash-resize-handle {
  opacity: .55;
  pointer-events: auto;
}
.dash-canvas.edit-mode .dash-resize-handle:hover { opacity: 1; color: var(--v5-primary); }

/* 변(edge) 핸들 — 카드 전체 변을 다 먹지 않도록 중앙 짧은 구간만 활성화 */
.dash-resize-handle.n { top: -3px; left: calc(50% - 36px); width: 72px; height: 6px; cursor: ns-resize; }
.dash-resize-handle.s { bottom: -3px; left: calc(50% - 36px); width: 72px; height: 6px; cursor: ns-resize; }
.dash-resize-handle.e { right: -3px; top: calc(50% - 36px); width: 6px; height: 72px; cursor: ew-resize; }
.dash-resize-handle.w { left: -3px; top: calc(50% - 36px); width: 6px; height: 72px; cursor: ew-resize; }

/* 코너(corner) 핸들 — 16x16 정사각형, 대각 커서 */
.dash-resize-handle.ne { top: -4px; right: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
.dash-resize-handle.nw { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.dash-resize-handle.se { bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.dash-resize-handle.sw { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: nesw-resize; }

/* 코너 시각 표식 */
.dash-resize-handle.ne::before,
.dash-resize-handle.nw::before,
.dash-resize-handle.se::before,
.dash-resize-handle.sw::before {
  content: ''; position: absolute; width: 8px; height: 8px;
  border: 2px solid currentColor; border-radius: 2px; background: var(--v5-surface-solid);
}
.dash-resize-handle.ne::before { top: 0; right: 0; }
.dash-resize-handle.nw::before { top: 0; left: 0; }
.dash-resize-handle.se::before { bottom: 0; right: 0; }
.dash-resize-handle.sw::before { bottom: 0; left: 0; }

/* 스냅 가이드 라인 — 드래그 중 다른 카드/캔버스 경계에 달라붙을 때 시각 표시 */
.dash-snap-guide {
  position: absolute; pointer-events: none; z-index: 100;
  opacity: .95;
  border-radius: 999px;
  background:
    linear-gradient(90deg,
      rgba(var(--v5-primary-rgb), 0),
      rgba(var(--v5-primary-rgb), .9) 18%,
      rgba(var(--v5-cyan-rgb), .95) 50%,
      rgba(var(--v5-primary-rgb), .9) 82%,
      rgba(var(--v5-primary-rgb), 0)
    );
  box-shadow:
    0 0 0 1px rgba(var(--v5-cyan-rgb), .22),
    0 0 14px rgba(var(--v5-cyan-rgb), .28);
}
.dash-snap-guide.v { width: 2px; }
.dash-snap-guide.h { height: 2px; }

/* ── 빈 대시보드 ── */
.dash-empty {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  color: var(--v5-text-muted); text-align: center;
}
.dash-empty-icon { font-size: 3rem; opacity: .25; }
.dash-empty-title { font-size: .95rem; font-weight: 700; color: var(--v5-text-sec); }
.dash-empty-desc { font-size: .65rem; color: var(--v5-text-muted);
  max-width: 280px; line-height: 1.5; }
.dash-empty-btn {
  margin-top: .4rem; padding: .5rem 1.2rem; border-radius: 10px; border: none;
  background: linear-gradient(135deg, var(--v5-primary), var(--v5-primary-light));
  color: white; font-size: .7rem; font-weight: 700; cursor: pointer;
  font-family: inherit; box-shadow: var(--v5-glow-sm); transition: all .2s;
}
.dash-empty-btn:hover { transform: translateY(-1px); box-shadow: var(--v5-glow-md); }

/* ── 라이브러리 모달 ── */
.dash-lib-backdrop {
  position: fixed; inset: 0; background: rgba(6,5,14,0.55);
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .3s var(--v5-ease-move);
}
.dash-lib-backdrop.open { opacity: 1; pointer-events: auto; }

.dash-lib-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(.96);
  width: min(920px, 90vw); height: min(620px, 85vh);
  background: var(--v5-surface-solid);
  border: 1px solid var(--v5-border); border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2), var(--v5-glow-lg);
  z-index: 201; display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; pointer-events: none; transition: all .3s var(--v5-ease-move);
}
.dash-lib-modal.open { opacity: 1; transform: translate(-50%,-50%) scale(1);
  pointer-events: auto; }

.dash-lib-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--v5-glass-border);
  flex-shrink: 0;
}
.dash-lib-title { font-size: .95rem; font-weight: 800; color: var(--v5-text); }
.dash-lib-close {
  width: 30px; height: 30px; border-radius: 9px;
  border: 1px solid var(--v5-glass-border); background: var(--v5-surface);
  color: var(--v5-text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.dash-lib-close:hover { border-color: var(--v5-red); color: var(--v5-red); }

.dash-lib-body { display: flex; flex: 1; overflow: hidden; }

.dash-lib-cats {
  width: 160px; flex-shrink: 0; background: var(--v5-bg-subtle);
  border-right: 1px solid var(--v5-border);
  padding: .7rem .5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1px;
}
.dash-lib-cat {
  display: flex; align-items: center; gap: .5rem; padding: .45rem .55rem;
  border-radius: 9px; font-size: .68rem; font-weight: 500;
  color: var(--v5-text-sec); cursor: pointer; transition: all .2s;
}
.dash-lib-cat:hover { background: var(--v5-surface-hover); color: var(--v5-text); }
.dash-lib-cat.on {
  background: linear-gradient(135deg, rgba(var(--v5-primary-rgb),.12), rgba(var(--v5-primary-rgb),.04));
  color: var(--v5-primary); font-weight: 600;
}

.dash-lib-grid { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; }
.dash-lib-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .7rem;
}
.dash-lib-card {
  padding: .85rem; border-radius: 13px; background: var(--v5-surface-solid);
  border: 1px solid var(--v5-border); cursor: pointer;
  transition: all .25s var(--v5-ease-move); display: flex; flex-direction: column; gap: .4rem;
}
.dash-lib-card:hover { border-color: var(--v5-primary);
  transform: translateY(-2px); box-shadow: var(--v5-glow-md); }
.dash-lib-card-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
  background: linear-gradient(135deg, rgba(var(--v5-primary-rgb),.15), rgba(var(--v5-cyan-rgb),.08));
  border: 1px solid rgba(var(--v5-primary-rgb),.15);
}
.dash-lib-card-thumb {
  position: relative; width: 100%; aspect-ratio: 16 / 10;
  border-radius: 8px; overflow: hidden; padding: 5px;
  background: var(--v5-surface);
  border: 1px solid var(--v5-border);
}
.dash-lib-card-thumb--empty {
  display: flex; align-items: center; justify-content: center;
}
.dash-lib-card-thumb--live {
  padding: 0;
  background: var(--v5-surface-solid);
}
.dash-lib-card-thumb-stage {
  transform-origin: top left;
  pointer-events: none;
  user-select: none;
}
.dash-lib-card-thumb-canvas {
  position: relative; width: 100%; height: 100%;
}
.dash-lib-card-thumb-block {
  position: absolute; border-radius: 1.5px;
  border: 1px solid transparent;
  box-sizing: border-box;
}
.dash-lib-card-name { font-size: .78rem; font-weight: 700; color: var(--v5-text); }
.dash-lib-card-desc { font-size: .55rem; color: var(--v5-text-muted); line-height: 1.4; }
.dash-lib-card-tag {
  font-size: .48rem; padding: .1rem .35rem; border-radius: 5px;
  background: rgba(var(--v5-primary-rgb),.08); color: var(--v5-primary); font-weight: 600;
  display: inline-block;
}

/* ── 카드 설정 패널 ── */
.dash-settings {
  position: absolute; top: 46px; right: 10px; width: 280px;
  max-height: calc(100% - 60px);
  background: var(--v5-surface-solid);
  border: 1px solid var(--v5-border); border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.15), var(--v5-glow-md);
  z-index: 60; display: flex; flex-direction: column; overflow: hidden;
}
.dash-settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem .85rem; border-bottom: 1px solid var(--v5-glass-border);
}
.dash-settings-title { font-size: .75rem; font-weight: 700; color: var(--v5-text); }
.dash-settings-body { flex: 1; overflow-y: auto; padding: .55rem .85rem .85rem; }
.dash-settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .4rem .1rem;
}
.dash-settings-row + .dash-settings-row { border-top: 1px dashed var(--v5-border-subtle); }
.dash-settings-label { font-size: .7rem; font-weight: 500; color: var(--v5-text-sec); }

/* 토글 스위치 */
.dash-toggle {
  position: relative; width: 32px; height: 18px; border-radius: 999px;
  background: var(--v5-surface); border: 1px solid var(--v5-glass-border);
  cursor: pointer; transition: all .25s; flex-shrink: 0;
}
.dash-toggle::after {
  content: ''; position: absolute; top: 1px; left: 1px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--v5-text-muted);
  transition: all .25s; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.dash-toggle.on {
  background: linear-gradient(135deg, var(--v5-primary), var(--v5-primary-light));
  border-color: transparent; box-shadow: var(--v5-glow-sm);
}
.dash-toggle.on::after { left: 15px; background: white; }

/* ── Toast ── */
.dash-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--v5-surface-solid); border: 1px solid var(--v5-border);
  border-radius: 12px; padding: .65rem 1.1rem;
  font-size: .7rem; font-weight: 600; color: var(--v5-text);
  box-shadow: 0 12px 40px rgba(0,0,0,.15), var(--v5-glow-md);
  z-index: 300; opacity: 0; pointer-events: none;
  transition: all .3s var(--v5-ease-move);
  display: flex; align-items: center; gap: .5rem;
}
.dash-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═══════════════════════════════════════════════════════════════════════════
   CRUD 액션 버튼 바 + 폼 오버레이 (DashboardCard Phase 2.1)
   ═══════════════════════════════════════════════════════════════════════════ */

.dash-card-crud-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .15rem 0;
  flex-wrap: wrap;
}
.dash-crud-btn {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .3rem .7rem;
  border-radius: 7px;
  border: 1px solid var(--v5-border);
  background: var(--v5-surface-solid);
  color: var(--v5-text-sec);
  font-size: .65rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s var(--v5-ease-move);
}
.dash-crud-btn:hover:not(:disabled) {
  border-color: var(--v5-primary);
  color: var(--v5-primary);
  background: rgba(var(--v5-primary-rgb),.08);
}
.dash-crud-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.dash-crud-btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--v5-primary), var(--v5-primary-light));
  color: #fff;
  box-shadow: var(--v5-glow-sm);
}
.dash-crud-btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
  color: #fff;
}
.dash-crud-btn.danger {
  color: var(--v5-red);
}
.dash-crud-btn.danger:hover:not(:disabled) {
  border-color: var(--v5-red);
  background: rgba(var(--v5-red-rgb),.08);
}
.dash-crud-note {
  margin-left: auto;
  font-size: .55rem;
  color: var(--v5-text-muted);
  font-style: italic;
}

/* narrow 모드 (카드 폭 < 520px) — 버튼 바 축약 */
@container card (max-width: 520px) {
  .dash-crud-btn {
    padding: .28rem .5rem;
    font-size: .6rem;
  }
  .dash-crud-btn > span {
    display: none;
  }
  .dash-crud-note {
    display: none;
  }
}

/* 등록/수정 폼 오버레이 */
.dash-form-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.5);
  animation: dashFormFade .2s ease-out;
}
.dash-form-modal {
  width: min(640px, 90%);
  max-height: 86%;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--v5-border);
  background: var(--v5-surface-solid);
  box-shadow: 0 24px 64px rgba(0,0,0,.35), var(--v5-glow-md);
  overflow: hidden;
}
.dash-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem .95rem;
  border-bottom: 1px solid var(--v5-border-subtle);
  background: transparent;
}
.dash-form-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--v5-text);
  letter-spacing: -.01em;
}
.dash-form-body {
  flex: 1;
  overflow: auto;
  padding: .85rem;
}
@keyframes dashFormFade {
  from { opacity: 0; transform: scale(.98); }
  to { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ud-* — INVYONE Design System (ui_kits/app) 포팅
   Floating Action Bar (FAB) + Header Tools (pop-out segment) + Card stagger.
   solid + glow 스타일 · 반투명/blur 미사용 (2026-04-21 정책).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── FAB: 캔버스 우하단 플로팅 액션 바 ── */
.ud-fab {
  position: absolute;
  bottom: 24px; right: 24px; z-index: 50;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 14px;
  background: var(--v5-surface-solid);
  border: 1px solid var(--v5-border);
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(0,0,0,.06),
    0 8px 24px rgba(var(--v5-primary-rgb), .14),
    var(--v5-glow-md);
  font-family: inherit;
  white-space: nowrap;
  transform-origin: bottom right;
  animation: ud-fab-in .42s cubic-bezier(.22,1.4,.36,1) both;
}
.dark .ud-fab {
  box-shadow:
    0 1px 2px rgba(0,0,0,.4),
    0 8px 24px rgba(var(--v5-primary-rgb), .25),
    var(--v5-glow-lg);
}
.ud-fab.closing {
  animation: ud-fab-out .3s var(--v5-ease-exit) both;
  pointer-events: none;
}
@keyframes ud-fab-in {
  from { opacity: 0; transform: translateY(16px) scale(.6); }
  60%  { transform: translateY(-2px) scale(1.08); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes ud-fab-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(12px) scale(.95); }
}
.ud-fab > * { animation: ud-fab-item-in .45s var(--v5-ease-move) both; }
.ud-fab > *:nth-child(1) { animation-delay: .06s; }
.ud-fab > *:nth-child(2) { animation-delay: .10s; }
.ud-fab > *:nth-child(3) { animation-delay: .14s; }
.ud-fab > *:nth-child(4) { animation-delay: .18s; }
.ud-fab > *:nth-child(5) { animation-delay: .22s; }
.ud-fab > *:nth-child(6) { animation-delay: .26s; }
@keyframes ud-fab-item-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ud-fab-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .68rem; font-weight: 700;
  color: rgb(var(--v5-primary-rgb));
  font-family: var(--v5-font-mono);
  letter-spacing: .02em;
  padding: 2px 4px;
}
.ud-fab-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgb(var(--v5-primary-rgb));
  box-shadow: 0 0 8px rgba(var(--v5-primary-rgb), .6);
  animation: ud-pulse 1.4s ease-in-out infinite;
}
.ud-fab-badge.ctrl { color: rgb(var(--v5-cyan-rgb)); }
.ud-fab-badge.ctrl .dot {
  background: rgb(var(--v5-cyan-rgb));
  box-shadow: 0 0 8px rgba(var(--v5-cyan-rgb), .6);
}
@keyframes ud-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

.ud-fab-sep {
  width: 1px; height: 18px;
  background: var(--v5-border);
  margin: 0 2px;
}

.ud-fab-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 12px;
  background: transparent;
  color: var(--v5-text-sec);
  font-size: .72rem; font-weight: 600;
  border: 1px solid transparent; border-radius: 8px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: all .18s var(--v5-ease-move);
}
.ud-fab-btn:hover {
  background: rgba(var(--v5-primary-rgb), .06);
  color: var(--v5-text);
}
.ud-fab-btn:active { transform: translateY(.5px); }
.ud-fab-btn.primary {
  background: rgb(var(--v5-primary-rgb));
  color: #fff;
  box-shadow: 0 2px 6px rgba(var(--v5-primary-rgb), .3);
}
.ud-fab-btn.primary:hover {
  filter: brightness(1.08);
  background: rgb(var(--v5-primary-rgb));
  color: #fff;
  box-shadow: 0 4px 10px rgba(var(--v5-primary-rgb), .4);
}
.ud-fab-btn.ghost { color: var(--v5-text-muted); }
.ud-fab-btn.ghost:hover {
  background: rgba(0,0,0,.04);
  color: var(--v5-text);
}
.dark .ud-fab-btn.ghost:hover { background: rgba(255,255,255,.05); }

/* ── Header Tools — segmented, underline active + color glow ── */
.ud-htools {
  display: inline-flex; align-items: center;
  padding: 0; isolation: isolate;
}

.ud-htool {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 14px;
  background: transparent;
  color: var(--v5-text-sec);
  font-size: .7rem; font-weight: 600; letter-spacing: -.005em;
  border: 0; border-radius: 0;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  transition: color .18s var(--v5-ease-move), text-shadow .22s var(--v5-ease-move);
  animation: ud-htool-in .45s var(--v5-ease-move) both;
}
.ud-htool + .ud-htool,
.ud-hsep + .ud-htool {
  box-shadow: -1px 0 0 0 rgba(var(--v5-primary-rgb), .12);
}
.ud-htool:hover { color: var(--v5-text); }
.ud-htool:active { transform: translateY(.5px); }
.ud-htool:focus { outline: none; }
.ud-htool:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(var(--v5-primary-rgb), .45);
}
.ud-htool:disabled { opacity: .4; cursor: not-allowed; }

.ud-htool.on {
  color: rgb(var(--v5-primary-rgb));
  background: transparent;
}
/* 언더라인 — 상시 존재, on/off 전환 시 양방향 scaleX transition */
.ud-htool::before {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: 4px;
  height: 2px;
  background: rgb(var(--v5-primary-rgb));
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left center;
  opacity: 0;
  transition:
    transform .35s var(--v5-ease-move),
    opacity .3s var(--v5-ease-move),
    background-color .22s var(--v5-ease-move),
    box-shadow .22s var(--v5-ease-move);
  pointer-events: none;
  box-shadow: 0 0 8px rgba(var(--v5-primary-rgb), .45);
}
.ud-htool.on::before {
  transform: scaleX(1);
  opacity: 1;
}
.ud-htool.on:hover { filter: brightness(1.1); }

/* 제어 모드 = cyan */
.ud-htool.on[data-mode="ctrl"] { color: rgb(var(--v5-cyan-rgb)); }
.ud-htool.on[data-mode="ctrl"]::before {
  background: rgb(var(--v5-cyan-rgb));
  box-shadow: 0 0 8px rgba(var(--v5-cyan-rgb), .45);
}

.ud-htool span { font-size: inherit; position: relative; z-index: 1; }
.ud-htool svg { position: relative; z-index: 1; }

.ud-hsep {
  width: 1px; height: 14px;
  background: rgba(var(--v5-primary-rgb), .14);
  margin: 0 2px;
  animation: ud-sep-in .45s var(--v5-ease-move) both;
}

/* 편집 모드 추가 버튼 그룹 — 편집 버튼 기준으로 왼쪽으로 펼쳐짐 (pop-out) */
.ud-htool-group {
  display: inline-flex; align-items: center;
  overflow: hidden;
  transform-origin: right center;
  animation: ud-htool-group-in .42s var(--v5-ease-move) both;
}
.ud-htool-group.closing {
  animation: ud-htool-group-out .32s var(--v5-ease-exit) both;
  pointer-events: none;
}
.ud-htool-group > * { animation: ud-htool-item-in .4s var(--v5-ease-move) both; }
/* 편집 버튼에서 먼 것부터 나타남 (오른쪽→왼쪽 순차 등장) */
.ud-htool-group > *:nth-child(3) { animation-delay: .04s; }
.ud-htool-group > *:nth-child(2) { animation-delay: .10s; }
.ud-htool-group > *:nth-child(1) { animation-delay: .16s; }
.ud-htool-group.closing > * { animation: ud-htool-item-out .26s var(--v5-ease-exit) both; }

@keyframes ud-htool-group-in {
  from { opacity: 0; max-width: 0; transform: translateX(12px); }
  to   { opacity: 1; max-width: 400px; transform: translateX(0); }
}
@keyframes ud-htool-group-out {
  from { opacity: 1; max-width: 400px; transform: translateX(0); }
  to   { opacity: 0; max-width: 0; transform: translateX(12px); }
}
@keyframes ud-htool-item-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes ud-htool-item-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(8px); }
}
@keyframes ud-htool-in {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes ud-sep-in {
  from { opacity: 0; transform: translateX(14px) scaleY(.3); }
  to   { opacity: 1; transform: translateX(0) scaleY(1); }
}

/* ── Header tool stagger: 오른쪽 끝(제어 근처) 부터 왼쪽으로 스르륵 ── */
.ud-htools > :nth-last-child(1) { animation-delay: 0ms; }
.ud-htools > :nth-last-child(2) { animation-delay: 35ms; }
.ud-htools > :nth-last-child(3) { animation-delay: 70ms; }
.ud-htools > :nth-last-child(4) { animation-delay: 105ms; }
.ud-htools > :nth-last-child(5) { animation-delay: 140ms; }
.ud-htools > :nth-last-child(6) { animation-delay: 175ms; }
.ud-htools > :nth-last-child(7) { animation-delay: 210ms; }

/* ud-htools 내부의 v5-hdr-sep + 외부 v5-hdr-sep 도 같은 슬라이드 */
.ud-htools > .v5-hdr-sep,
.ud-htools + .v5-hdr-sep {
  animation: ud-htool-in .45s var(--v5-ease-move) both;
}

/* ── 카드 stagger: dash-canvas 내부 카드가 index × 35ms delay로 등장 ── */
.dash-canvas > [data-card-id] {
  animation: ud-card-in .55s var(--v5-ease-move) both;
}
.dash-canvas > [data-card-id]:nth-child(1)  { animation-delay: 35ms; }
.dash-canvas > [data-card-id]:nth-child(2)  { animation-delay: 70ms; }
.dash-canvas > [data-card-id]:nth-child(3)  { animation-delay: 105ms; }
.dash-canvas > [data-card-id]:nth-child(4)  { animation-delay: 140ms; }
.dash-canvas > [data-card-id]:nth-child(5)  { animation-delay: 175ms; }
.dash-canvas > [data-card-id]:nth-child(6)  { animation-delay: 210ms; }
.dash-canvas > [data-card-id]:nth-child(7)  { animation-delay: 245ms; }
.dash-canvas > [data-card-id]:nth-child(8)  { animation-delay: 280ms; }
.dash-canvas > [data-card-id]:nth-child(9)  { animation-delay: 315ms; }
.dash-canvas > [data-card-id]:nth-child(10) { animation-delay: 350ms; }
.dash-canvas > [data-card-id]:nth-child(n+11) { animation-delay: 385ms; }
@keyframes ud-card-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 모드 배지: 캔버스 좌상단 혹은 FAB 왼쪽에서 재활용 ── */
.ud-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .58rem; font-weight: 700;
  padding: .22rem .6rem;
  border-radius: 999px;
  font-family: var(--v5-font-mono);
  letter-spacing: .04em;
}
.ud-badge.edit {
  background: rgba(var(--v5-primary-rgb), .12);
  color: rgb(var(--v5-primary-rgb));
  border: 1px solid rgba(var(--v5-primary-rgb), .25);
}
.ud-badge.edit .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgb(var(--v5-primary-rgb));
  box-shadow: 0 0 8px rgba(var(--v5-primary-rgb), .6);
  animation: ud-pulse 1.4s ease-in-out infinite;
}
.ud-badge.ctrl {
  background: rgba(var(--v5-cyan-rgb), .12);
  color: rgb(var(--v5-cyan-rgb));
  border: 1px solid rgba(var(--v5-cyan-rgb), .25);
}
