/* ============================================================
   Piazza Studio Components — Storybook chrome
   Sidebar (left) + content area + top bar + story card frame.
   Brand-grounded; uses only --mp-* tokens.
   ============================================================ */

*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--mp-bg-soft);
  color: var(--mp-fg);
  font-family: var(--mp-font-sans);
  min-height: 100vh;
}

button { font-family: inherit; }

/* ---- App shell ---- */

.cp-app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */

.cp-side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--mp-white);
  border-right: 1px solid var(--mp-border);
  overflow: hidden;
}

.cp-side__brand {
  display: flex;
  align-items: center;
  gap: var(--mp-space-3);
  padding: var(--mp-space-5) var(--mp-space-5) var(--mp-space-4);
  border-bottom: 1px solid var(--mp-border);
}
.cp-side__brand img { height: 22px; display: block; }

/* ---- Sidebar project switcher ---- */
.cp-sideProj {
  position: relative;
  padding: var(--mp-space-3) var(--mp-space-3) var(--mp-space-4);
  border-bottom: 1px solid var(--mp-border);
}
.cp-sideProj__row { display: flex; gap: var(--mp-space-2); align-items: stretch; }
.cp-sideProj__trigger {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  padding: 6px var(--mp-space-3);
  background: var(--mp-bg-soft);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: var(--mp-font-sans);
  color: var(--mp-fg);
  position: relative;
  transition: border-color var(--mp-duration-fast), background var(--mp-duration-fast);
}
.cp-sideProj__trigger:hover { border-color: var(--mp-border-strong); background: var(--mp-white); }
.cp-sideProj__eyebrow {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: var(--mp-tracking-caps);
  text-transform: uppercase;
  color: var(--mp-fg-subtle);
  line-height: 1;
}
.cp-sideProj__name {
  font-size: 13px;
  font-weight: 700;
  color: var(--mp-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  padding-right: 14px;
}
.cp-sideProj__caret {
  position: absolute;
  top: 50%;
  right: var(--mp-space-2);
  transform: translateY(-50%);
  color: var(--mp-fg-subtle);
}
.cp-sideProj__new {
  width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mp-primary);
  border: 1px solid var(--mp-primary);
  border-radius: var(--mp-radius-sm);
  color: var(--mp-primary-fg);
  cursor: pointer;
  transition: background var(--mp-duration-fast);
  flex-shrink: 0;
}
.cp-sideProj__new:hover { background: var(--mp-primary-hover); border-color: var(--mp-primary-hover); }
.cp-sideProj__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: var(--mp-space-3);
  right: var(--mp-space-3);
  max-height: 360px;
  overflow-y: auto;
  padding: var(--mp-space-2);
  background: var(--mp-white);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-md);
  box-shadow: var(--mp-shadow-lg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cp-side__sub {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--mp-tracking-caps);
  color: var(--mp-fg-muted);
  padding: 0 var(--mp-space-5);
  margin: var(--mp-space-5) 0 var(--mp-space-2);
}
.cp-side__nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--mp-space-3) var(--mp-space-6);
}
.cp-side__group {
  margin-bottom: var(--mp-space-2);
}
.cp-side__groupTitle {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--mp-tracking-caps);
  color: var(--mp-fg-subtle);
  padding: var(--mp-space-4) var(--mp-space-3) var(--mp-space-2);
}
.cp-side__item {
  display: flex;
  align-items: center;
  gap: var(--mp-space-3);
  width: 100%;
  padding: var(--mp-space-2) var(--mp-space-3);
  border-radius: var(--mp-radius-sm);
  background: transparent;
  border: 0;
  color: var(--mp-fg);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--mp-duration-fast) var(--mp-ease-standard),
              color var(--mp-duration-fast) var(--mp-ease-standard);
}
.cp-side__item:hover {
  background: var(--mp-bg-soft);
  color: var(--mp-fg);
}
.cp-side__item.is-active {
  background: var(--mp-fg);
  color: var(--mp-white);
}
.cp-side__item.is-active .cp-side__count {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
}
.cp-side__count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--mp-radius-pill);
  background: var(--mp-bg-soft);
  color: var(--mp-fg-muted);
  font-variant-numeric: tabular-nums;
}

.cp-side__foot {
  padding: var(--mp-space-4) var(--mp-space-5);
  border-top: 1px solid var(--mp-border);
  font-size: 12px;
  color: var(--mp-fg-muted);
  line-height: 1.4;
}
.cp-side__foot strong { color: var(--mp-fg); display: block; font-weight: 700; }

/* ---- Main column ---- */

.cp-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cp-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--mp-space-5);
  padding: var(--mp-space-4) var(--mp-space-7);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--mp-border);
}
.cp-top__crumb {
  font-size: 12px;
  color: var(--mp-fg-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--mp-tracking-caps);
}
.cp-top__crumb span { color: var(--mp-fg); }
.cp-top__actions { display: flex; gap: var(--mp-space-2); align-items: center; }
.cp-top__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--mp-space-2);
  height: 36px;
  padding: 0 var(--mp-space-4);
  border: 1px solid var(--mp-border-strong);
  background: var(--mp-white);
  border-radius: var(--mp-radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--mp-fg);
  cursor: pointer;
  transition: border-color var(--mp-duration-fast), background var(--mp-duration-fast);
}
.cp-top__btn:hover { border-color: var(--mp-fg); }
.cp-top__btn i[data-lucide] { width: 14px; height: 14px; }

.cp-top__btn--primary {
  background: var(--mp-primary);
  border-color: var(--mp-primary);
  color: var(--mp-primary-fg);
}
.cp-top__btn--primary:hover {
  background: var(--mp-primary-hover);
  border-color: var(--mp-primary-hover);
}

/* ---- Viewport switch (segmented control) ---- */
.cp-vp-switch {
  display: inline-flex;
  align-items: center;
  background: var(--mp-bg-soft);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  padding: 2px;
  gap: 2px;
  height: 36px;
  box-sizing: border-box;
}
.cp-vp-switch__btn {
  width: 36px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--mp-fg-muted);
  cursor: pointer;
  transition: background var(--mp-duration-fast), color var(--mp-duration-fast), box-shadow var(--mp-duration-fast);
}
.cp-vp-switch__btn:hover { color: var(--mp-fg); }
.cp-vp-switch__btn.is-active {
  background: var(--mp-white);
  color: var(--mp-primary);
  box-shadow: 0 1px 2px rgba(29, 53, 87, 0.12);
}

/* ---- Project dropdown ---- */
.cp-projDrop { position: relative; }
.cp-projDrop__trigger {
  padding-left: var(--mp-space-3);
  padding-right: var(--mp-space-3);
  min-width: 200px;
  text-align: left;
}
.cp-projDrop__triggerLabel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.cp-projDrop__triggerLabel > span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.cp-projDrop__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  max-width: 360px;
  max-height: 360px;
  overflow-y: auto;
  padding: var(--mp-space-2);
  background: var(--mp-white);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-md);
  box-shadow: var(--mp-shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cp-projDrop__empty {
  padding: var(--mp-space-4);
  text-align: center;
  font-size: 13px;
  color: var(--mp-fg-muted);
}
.cp-projDrop__item {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-radius: var(--mp-radius-sm);
  background: transparent;
  transition: background var(--mp-duration-fast);
}
.cp-projDrop__item:hover { background: var(--mp-bg-soft); }
.cp-projDrop__item.is-active {
  background: color-mix(in srgb, var(--mp-primary) 8%, var(--mp-white));
  box-shadow: inset 2px 0 0 var(--mp-primary);
}
.cp-projDrop__pick {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--mp-space-2) var(--mp-space-3);
  background: transparent;
  border: 0;
  border-radius: var(--mp-radius-sm) 0 0 var(--mp-radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: var(--mp-font-sans);
  color: var(--mp-fg);
  min-width: 0;
}
.cp-projDrop__delete {
  flex-shrink: 0;
  width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 0 var(--mp-radius-sm) var(--mp-radius-sm) 0;
  color: var(--mp-fg-subtle);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--mp-duration-fast), color var(--mp-duration-fast), background var(--mp-duration-fast);
}
.cp-projDrop__item:hover .cp-projDrop__delete,
.cp-projDrop__delete:focus-visible { opacity: 1; }
.cp-projDrop__delete:hover {
  color: var(--mp-danger);
  background: color-mix(in srgb, var(--mp-danger) 10%, transparent);
}
.cp-projDrop__itemName { font-size: 14px; font-weight: 700; color: var(--mp-fg); }
.cp-projDrop__itemDesc { font-size: 12px; color: var(--mp-fg-muted); line-height: 1.4; }

/* ---- Confirm dialog variant ---- */
.cp-modal--confirm { max-width: 440px; }
.cp-modal--confirm.is-danger .cp-modal__title { color: var(--mp-danger); }
.cp-btn--danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--mp-space-2);
  height: 40px;
  padding: 0 var(--mp-space-4);
  font-family: var(--mp-font-sans);
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--mp-radius-sm);
  border: 1px solid transparent;
  background: var(--mp-danger);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--mp-duration-fast), transform var(--mp-duration-fast);
}
.cp-btn--danger:hover { background: color-mix(in srgb, var(--mp-danger) 85%, #000); }
.cp-btn--danger:active { transform: translateY(1px); }
.cp-btn--danger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mp-danger) 35%, transparent);
}

/* ---- Modal ---- */
.cp-modal__back {
  position: fixed;
  inset: 0;
  background: rgba(10, 21, 48, 0.55);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--mp-space-5);
  animation: cp-modal-fade .14s ease;
}
@keyframes cp-modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.cp-modal {
  width: 100%;
  max-width: 480px;
  background: var(--mp-white);
  border-radius: var(--mp-radius-md);
  box-shadow: var(--mp-shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: cp-modal-slide .18s var(--mp-ease-out);
}
@keyframes cp-modal-slide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cp-modal__head {
  padding: var(--mp-space-5) var(--mp-space-5) var(--mp-space-4);
  border-bottom: 1px solid var(--mp-border);
}
.cp-modal__title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--mp-fg);
}
.cp-modal__sub {
  margin: var(--mp-space-2) 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--mp-fg-muted);
}
.cp-modal__body {
  padding: var(--mp-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--mp-space-4);
}
.cp-modal__field {
  display: flex;
  flex-direction: column;
  gap: var(--mp-space-2);
}
.cp-modal__field > span {
  font-size: 13px;
  font-weight: 700;
  color: var(--mp-fg);
}
.cp-modal__field > span em {
  color: var(--mp-danger);
  font-style: normal;
  font-weight: 700;
}
.cp-modal__field input {
  height: 40px;
  padding: 0 var(--mp-space-3);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  font: 400 14px var(--mp-font-sans);
  color: var(--mp-fg);
  background: var(--mp-white);
  outline: none;
  transition: border-color var(--mp-duration-fast), box-shadow var(--mp-duration-fast);
}
.cp-modal__field input:focus {
  border-color: var(--mp-primary);
  box-shadow: 0 0 0 3px var(--mp-focus-ring);
}
.cp-modal__foot {
  padding: var(--mp-space-4) var(--mp-space-5);
  border-top: 1px solid var(--mp-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--mp-space-2);
  background: var(--mp-bg-soft);
}

/* Theme-scope wrapper — neutral container; carries the project's
   --mp-* tokens via inline style so chrome (sidebar/topbar/modals)
   keeps the stylesheet defaults from colors_and_type.css. */
.cp-theme-scope { display: contents; }

/* ---- Icon-Button + Lucide picker ---- */
.bx-iconbtn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: var(--mp-space-2);
}
.bx-iconbtn__token {
  font-family: var(--mp-font-mono);
  font-size: 11px;
  color: var(--mp-fg-subtle);
  letter-spacing: 0.04em;
}
.bx-iconbtn__pop {
  position: absolute;
  top: calc(100% + var(--mp-space-3));
  left: 50%;
  transform: translateX(-50%);
  width: 360px;
  max-width: 90vw;
  background: var(--mp-white);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-md);
  box-shadow: var(--mp-shadow-lg);
  z-index: 60;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.bx-iconbtn__head {
  padding: var(--mp-space-3);
  border-bottom: 1px solid var(--mp-border);
  display: flex;
  align-items: center;
  gap: var(--mp-space-2);
  background: var(--mp-bg-soft);
}
.bx-iconbtn__search {
  flex: 1;
  height: 32px;
  padding: 0 var(--mp-space-3);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  background: var(--mp-white);
  font: 400 13px var(--mp-font-sans);
  outline: none;
  color: var(--mp-fg);
}
.bx-iconbtn__search:focus {
  border-color: var(--mp-primary);
  box-shadow: 0 0 0 3px var(--mp-focus-ring);
}
.bx-iconbtn__count {
  font-family: var(--mp-font-mono);
  font-size: 11px;
  color: var(--mp-fg-muted);
  padding: 0 var(--mp-space-2);
  font-variant-numeric: tabular-nums;
}
.bx-iconbtn__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: var(--mp-space-3);
  max-height: 280px;
  overflow-y: auto;
}
.bx-iconbtn__cell {
  width: 100%;
  aspect-ratio: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--mp-radius-sm);
  color: var(--mp-fg);
  cursor: pointer;
  transition: background var(--mp-duration-fast), border-color var(--mp-duration-fast), color var(--mp-duration-fast);
}
.bx-iconbtn__cell:hover {
  background: var(--mp-bg-soft);
  color: var(--mp-primary);
}
.bx-iconbtn__cell.is-active {
  background: color-mix(in srgb, var(--mp-primary) 12%, var(--mp-white));
  border-color: var(--mp-primary);
  color: var(--mp-primary);
}
.bx-iconbtn__cell i[data-lucide] { width: 18px; height: 18px; }
.bx-iconbtn__empty {
  grid-column: 1 / -1;
  padding: var(--mp-space-5);
  text-align: center;
  color: var(--mp-fg-muted);
  font-size: 13px;
}
.bx-iconbtn__foot {
  padding: var(--mp-space-2) var(--mp-space-3);
  border-top: 1px solid var(--mp-border);
  background: var(--mp-bg-soft);
  font-size: 11px;
  font-family: var(--mp-font-mono);
  color: var(--mp-fg-subtle);
  text-align: center;
}

/* ---- Story page ---- */

.cp-page {
  padding: var(--mp-space-7) var(--mp-space-7) var(--mp-space-10);
  max-width: 1280px;
  width: 100%;
}

.cp-page__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--mp-space-5);
  padding-bottom: var(--mp-space-6);
  border-bottom: 1px solid var(--mp-border);
  margin-bottom: var(--mp-space-7);
}
.cp-page__title h1 {
  font-family: var(--mp-font-sans);
  text-transform: none;
  font-weight: 900;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
}
.cp-page__title .mp-eyebrow {
  display: block;
  margin-bottom: var(--mp-space-3);
}
.cp-page__desc {
  font-size: 16px;
  line-height: 1.6;
  color: var(--mp-fg-muted);
  max-width: 56ch;
  margin: var(--mp-space-3) 0 0;
  text-wrap: pretty;
}
.cp-page__meta {
  display: flex;
  gap: var(--mp-space-6);
  flex-shrink: 0;
}
.cp-page__metaItem dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--mp-tracking-caps);
  color: var(--mp-fg-subtle);
}
.cp-page__metaItem dd {
  margin: var(--mp-space-1) 0 0;
  font-family: var(--mp-font-display);
  font-size: 22px;
  color: var(--mp-fg);
}

/* ---- Story card ---- */

.cp-story {
  margin-bottom: var(--mp-space-7);
}
.cp-story__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--mp-space-4);
  margin-bottom: var(--mp-space-3);
}
.cp-story__label {
  display: flex;
  align-items: baseline;
  gap: var(--mp-space-3);
}
.cp-story__num {
  font-family: var(--mp-font-mono);
  font-size: 11px;
  color: var(--mp-fg-subtle);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.cp-story__name {
  font-size: 18px;
  font-weight: 700;
  color: var(--mp-fg);
  margin: 0;
}
.cp-story__desc {
  font-size: 13px;
  color: var(--mp-fg-muted);
  max-width: 50ch;
  text-align: right;
  line-height: 1.5;
  margin: 0;
}
.cp-story__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--mp-space-2);
  margin-top: var(--mp-space-2);
}
.cp-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--mp-space-1);
  height: 22px;
  padding: 0 var(--mp-space-2);
  border-radius: var(--mp-radius-pill);
  background: var(--mp-bg-soft);
  border: 1px solid var(--mp-border);
  font-size: 11px;
  font-weight: 700;
  color: var(--mp-fg-muted);
  font-family: var(--mp-font-mono);
}
.cp-tag--accent { background: color-mix(in srgb, var(--mp-primary) 8%, transparent); color: var(--mp-primary); border-color: color-mix(in srgb, var(--mp-primary) 25%, transparent); }

.cp-frame {
  position: relative;
  background: var(--mp-white);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  overflow: hidden;
  box-shadow: var(--mp-shadow-xs);
}
.cp-frame--soft { background: var(--mp-bg-soft); }
.cp-frame--dark { background: var(--mp-dark-blue); }
.cp-frame--checker {
  background-image:
    linear-gradient(45deg, var(--mp-ink-100) 25%, transparent 25%),
    linear-gradient(-45deg, var(--mp-ink-100) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--mp-ink-100) 75%),
    linear-gradient(-45deg, transparent 75%, var(--mp-ink-100) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #fff;
}

.cp-frame__pad { padding: var(--mp-space-7) var(--mp-space-7); }
.cp-frame__pad--sm { padding: var(--mp-space-5); }
.cp-frame__pad--lg { padding: var(--mp-space-8) var(--mp-space-7); }
.cp-frame__pad--flush { padding: 0; }

/* Resize handle / variant width pickers (visual only) */
.cp-frame__viewport {
  display: flex;
  align-items: center;
  gap: var(--mp-space-3);
  padding: var(--mp-space-2) var(--mp-space-4);
  border-bottom: 1px solid var(--mp-border);
  background: var(--mp-bg-soft);
  font-family: var(--mp-font-mono);
  font-size: 11px;
  color: var(--mp-fg-muted);
}
.cp-frame__viewport b { color: var(--mp-fg); font-weight: 700; }
.cp-frame__dot { width: 10px; height: 10px; border-radius: 999px; background: var(--mp-primary); display: inline-block; }
.cp-frame__dot.gr { background: #1f9d55; }
.cp-frame__dot.ye { background: #d97706; }

/* ---- Helpers ---- */

.cp-hr {
  border: 0;
  border-top: 1px solid var(--mp-border);
  margin: var(--mp-space-8) 0;
}

.cp-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--mp-space-5); }
.cp-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--mp-space-5); }
.cp-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--mp-space-4); }

.cp-note {
  background: var(--mp-bg-soft);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  padding: var(--mp-space-4) var(--mp-space-5);
  font-size: 13px;
  color: var(--mp-fg-muted);
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: var(--mp-space-3);
}
.cp-note i[data-lucide] { width: 16px; height: 16px; color: var(--mp-primary); flex-shrink: 0; margin-top: 1px; }
.cp-note strong { color: var(--mp-fg); font-weight: 700; }

.cp-codeline {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--mp-font-mono);
  font-size: 11px;
  background: var(--mp-bg-soft);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  color: var(--mp-fg);
}

/* Token cards reused across foundations */
.cp-swatch {
  background: var(--mp-white);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  overflow: hidden;
}
.cp-swatch__chip {
  height: 96px;
  display: flex;
  align-items: flex-end;
  padding: var(--mp-space-3);
}
.cp-swatch__body {
  padding: var(--mp-space-3) var(--mp-space-4) var(--mp-space-4);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cp-swatch__name { font-size: 13px; font-weight: 700; color: var(--mp-fg); }
.cp-swatch__token { font-size: 11px; font-family: var(--mp-font-mono); color: var(--mp-fg-muted); }
.cp-swatch__hex { font-size: 11px; font-family: var(--mp-font-mono); color: var(--mp-fg-subtle); }

/* Empty / disabled feedback */
.cp-emptyBlock {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mp-fg-subtle);
  font-size: 13px;
  border: 1px dashed var(--mp-border-strong);
  border-radius: var(--mp-radius-md);
  padding: var(--mp-space-7);
}

/* Welcome / dashboard hero */
.cp-welcome {
  background: var(--mp-dark-blue);
  color: var(--mp-fg-inverse);
  border-radius: var(--mp-radius-md);
  padding: var(--mp-space-8) var(--mp-space-7);
  margin-bottom: var(--mp-space-7);
  position: relative;
  overflow: hidden;
}
.cp-welcome__eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: var(--mp-tracking-caps);
  text-transform: uppercase;
  color: var(--mp-cyan);
  margin-bottom: var(--mp-space-4);
  display: flex;
  align-items: center;
  gap: var(--mp-space-2);
}
.cp-welcome__title {
  font-family: var(--mp-font-display);
  font-size: clamp(40px, 5vw, 72px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 0 0 var(--mp-space-5);
  color: var(--mp-white);
}
.cp-welcome__lead {
  font-size: 18px;
  line-height: 1.55;
  font-weight: 300;
  color: rgba(255,255,255,0.78);
  max-width: 60ch;
  margin: 0;
}
.cp-welcome__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--mp-space-5);
  margin-top: var(--mp-space-7);
  padding-top: var(--mp-space-5);
  border-top: 1px solid rgba(255,255,255,0.12);
}
.cp-welcome__stats dt { font-size: 11px; letter-spacing: var(--mp-tracking-caps); text-transform: uppercase; color: rgba(255,255,255,0.55); font-weight: 700; }
.cp-welcome__stats dd { margin: var(--mp-space-2) 0 0; font-family: var(--mp-font-display); font-size: 36px; color: var(--mp-white); }
.cp-welcome__signet {
  position: absolute;
  right: -40px;
  top: -40px;
  width: 280px;
  opacity: 0.07;
  pointer-events: none;
}

/* ---- Overview cards ---- */
.cp-overview-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--mp-space-3);
  padding: var(--mp-space-5);
  background: var(--mp-white);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  text-align: left;
  cursor: pointer;
  min-height: 160px;
  transition: box-shadow var(--mp-duration-base) var(--mp-ease-standard),
              transform var(--mp-duration-base) var(--mp-ease-standard),
              border-color var(--mp-duration-base) var(--mp-ease-standard);
  font-family: var(--mp-font-sans);
  color: inherit;
}
.cp-overview-card:hover {
  box-shadow: var(--mp-shadow-md);
  transform: translateY(-2px);
  border-color: var(--mp-border-strong);
}
.cp-overview-card__icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mp-bg-soft);
  border-radius: var(--mp-radius-sm);
  color: var(--mp-primary);
}
.cp-overview-card__icon i[data-lucide] { width: 18px; height: 18px; }
.cp-overview-card__num {
  position: absolute;
  top: var(--mp-space-4);
  right: var(--mp-space-5);
  font-family: var(--mp-font-mono);
  font-size: 11px;
  color: var(--mp-fg-subtle);
  letter-spacing: 0.04em;
}
.cp-overview-card__name {
  font-size: 18px;
  font-weight: 700;
  color: var(--mp-fg);
  margin-top: auto;
}
.cp-overview-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--mp-primary);
}
.cp-overview-card__cta i[data-lucide] { width: 14px; height: 14px; transition: transform var(--mp-duration-base); }
.cp-overview-card:hover .cp-overview-card__cta i[data-lucide] { transform: translateX(3px); }

/* ============================================================
   Studio — Theme Editor + Export
   ============================================================ */

.st-groupTitle {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: var(--mp-tracking-caps);
  text-transform: uppercase;
  color: var(--mp-fg-subtle);
  margin-bottom: var(--mp-space-3);
}

/* ---- Color editor ---- */
.st-colorGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--mp-space-6);
}
.st-colorGroup { display: flex; flex-direction: column; }
.st-colorList { display: flex; flex-direction: column; gap: var(--mp-space-2); }
.st-color {
  display: flex;
  align-items: center;
  gap: var(--mp-space-3);
  padding: var(--mp-space-2);
  border-radius: var(--mp-radius-sm);
  border: 1px solid var(--mp-border);
  background: var(--mp-white);
  position: relative;
  transition: border-color var(--mp-duration-fast);
}
.st-color:hover { border-color: var(--mp-border-strong); }
.st-color__swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--mp-radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.st-color__meta { flex: 1; min-width: 0; }
.st-color__name { font-size: 13px; font-weight: 700; color: var(--mp-fg); }
.st-color__token { font-size: 11px; font-family: var(--mp-font-mono); color: var(--mp-fg-muted); }
.st-color__hex {
  width: 96px;
  height: 30px;
  padding: 0 var(--mp-space-2);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  font: 600 12px var(--mp-font-mono);
  text-align: center;
  background: var(--mp-bg-soft);
  color: var(--mp-fg);
  outline: none;
  text-transform: uppercase;
}
.st-color__hex:focus { border-color: var(--mp-primary); box-shadow: 0 0 0 3px var(--mp-focus-ring); }

/* ---- Font editor ---- */
.st-fontGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--mp-space-5);
}
.st-font {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  background: var(--mp-bg-soft);
  padding: var(--mp-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--mp-space-4);
}
.st-font__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--mp-space-4);
  flex-wrap: wrap;
}
.st-font__role {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: var(--mp-tracking-caps);
  text-transform: uppercase;
  color: var(--mp-fg-subtle);
  margin-bottom: var(--mp-space-2);
}
.st-font__family {
  width: 240px;
  max-width: 100%;
  height: 36px;
  padding: 0 var(--mp-space-3);
  border: 1px solid var(--mp-border-strong);
  background: var(--mp-white);
  border-radius: var(--mp-radius-sm);
  font: 700 14px var(--mp-font-sans);
  color: var(--mp-fg);
  outline: none;
}
.st-font__family:focus { border-color: var(--mp-primary); box-shadow: 0 0 0 3px var(--mp-focus-ring); }
.st-font__actions { display: flex; gap: var(--mp-space-2); align-items: center; flex-shrink: 0; }
.st-font__preview {
  background: var(--mp-white);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  padding: var(--mp-space-5);
  font-size: 22px;
  line-height: 1.3;
  color: var(--mp-fg);
  min-height: 120px;
  display: flex;
  align-items: center;
}
.st-font__hint { font-size: 12px; color: var(--mp-fg-muted); display: flex; gap: var(--mp-space-2); align-items: center; }

/* ---- Type scale editor ---- */
.st-scaleList { display: flex; flex-direction: column; }
.st-scaleRow {
  display: grid;
  grid-template-columns: 140px 110px 1fr;
  gap: var(--mp-space-5);
  align-items: center;
  padding: var(--mp-space-4) 0;
  border-bottom: 1px solid var(--mp-border);
}
.st-scaleRow:last-child { border-bottom: 0; }
.st-scaleRow__meta { display: flex; flex-direction: column; gap: 2px; }
.st-scaleRow__label { font-size: 14px; font-weight: 700; color: var(--mp-fg); }
.st-scaleRow__token { font-size: 11px; font-family: var(--mp-font-mono); color: var(--mp-fg-muted); }
.st-scaleRow__note { font-size: 11px; color: var(--mp-fg-subtle); }
.st-scaleRow__input {
  display: flex;
  align-items: center;
  gap: var(--mp-space-2);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  background: var(--mp-white);
  padding: 0 var(--mp-space-2) 0 var(--mp-space-3);
  height: 40px;
}
.st-scaleRow__input input {
  flex: 1;
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font: 700 14px var(--mp-font-mono);
  color: var(--mp-fg);
  font-variant-numeric: tabular-nums;
}
.st-scaleRow__input input::-webkit-outer-spin-button,
.st-scaleRow__input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.st-scaleRow__input span { font-size: 12px; color: var(--mp-fg-subtle); padding-right: var(--mp-space-1); }
.st-scaleRow__preview {
  color: var(--mp-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}

/* ---- Radius editor ---- */
.st-radius {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--mp-space-6);
  align-items: center;
}
.st-radius__preview {
  display: flex;
  gap: var(--mp-space-4);
  justify-content: center;
}
.st-radius__preview > div {
  width: 88px;
  height: 88px;
  background: var(--mp-bg-soft);
  border: 1px solid var(--mp-border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 12px var(--mp-font-mono);
  color: var(--mp-fg-muted);
  text-transform: uppercase;
  letter-spacing: var(--mp-tracking-caps);
}

/* ---- Export ---- */
.st-export {
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  overflow: hidden;
  background: var(--mp-white);
}
.st-export__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--mp-space-3) var(--mp-space-4);
  background: var(--mp-bg-soft);
  border-bottom: 1px solid var(--mp-border);
  gap: var(--mp-space-4);
}
.st-export__name { font-size: 13px; font-weight: 700; color: var(--mp-fg); }
.st-export__lang { font-size: 11px; color: var(--mp-fg-muted); font-family: var(--mp-font-mono); letter-spacing: var(--mp-tracking-caps); text-transform: uppercase; }
.st-export__pre {
  margin: 0;
  padding: var(--mp-space-5);
  font-family: var(--mp-font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--mp-fg);
  background: var(--mp-white);
  overflow-x: auto;
  max-height: 360px;
  overflow-y: auto;
  white-space: pre;
  tab-size: 2;
}

/* ---- Color picker popover ---- */
.st-picker {
  z-index: 9999;
  width: 264px;
  padding: 12px;
  background: var(--mp-white);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-md);
  box-shadow: var(--mp-shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--mp-font-sans);
  color: var(--mp-fg);
  user-select: none;
}
.st-picker__sv {
  position: relative;
  width: 100%;
  height: 168px;
  border-radius: var(--mp-radius-sm);
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}
.st-picker__sv-white {
  position: absolute; inset: 0;
  background: linear-gradient(to right, #fff, transparent);
}
.st-picker__sv-black {
  position: absolute; inset: 0;
  background: linear-gradient(to top, #000, transparent);
}
.st-picker__sv-handle {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.st-picker__hue {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(to right,
    #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%,
    #0000ff 67%, #ff00ff 83%, #ff0000 100%);
  cursor: ew-resize;
  touch-action: none;
}
.st-picker__hue-handle {
  position: absolute;
  top: 50%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.st-picker__row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.st-picker__preview {
  width: 36px; height: 36px;
  border-radius: var(--mp-radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}
.st-picker__inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.st-picker__field {
  display: flex;
  align-items: center;
  height: 28px;
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  overflow: hidden;
  background: var(--mp-white);
}
.st-picker__field span {
  font: 700 10px var(--mp-font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--mp-fg-subtle);
  padding: 0 8px;
  border-right: 1px solid var(--mp-border);
  background: var(--mp-bg-soft);
  height: 100%;
  display: inline-flex;
  align-items: center;
}
.st-picker__field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  height: 100%;
  background: transparent;
  font: 600 12px var(--mp-font-mono);
  padding: 0 8px;
  color: var(--mp-fg);
  text-transform: uppercase;
}
.st-picker__field input:focus { background: var(--mp-bg-soft); }
.st-picker__field--num input::-webkit-outer-spin-button,
.st-picker__field--num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.st-picker__field--num input { text-transform: none; text-align: center; }
.st-picker__rgb {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}
.st-picker__foot {
  display: flex;
  align-items: center;
  gap: 8px;
}
.st-picker__icon {
  width: 28px; height: 28px;
  border-radius: var(--mp-radius-sm);
  border: 1px solid var(--mp-border-strong);
  background: var(--mp-white);
  color: var(--mp-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.st-picker__icon:hover { border-color: var(--mp-fg); }
.st-picker__icon i[data-lucide] { width: 14px; height: 14px; }
.st-picker__recents {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 20px;
}
.st-picker__empty {
  font-size: 11px;
  color: var(--mp-fg-subtle);
  align-self: center;
}
.st-picker__swatch {
  width: 20px; height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  padding: 0;
  background: transparent;
}
.st-picker__swatch:hover { transform: scale(1.1); }

/* ============================================================
   Builder — full-width Layout
   Linke Spalte: Komponenten-Menü (full height)
   Rechte Spalte: Stage (Header + Upload / Workspace)
   Workspace = Preview (flex) + Inspector (320 px)
   ============================================================ */

/* Page-wrapper override: builder fills the viewport */
.cp-page:has(.bd-shell) {
  max-width: none;
  width: 100%;
  padding: 0;
}

/* Builder shell — three docked columns. Widths set inline via JS
   (resizable). The center stage gets the gutter (padding) so menu
   and inspector look flush against the viewport edges. */
.bd-shell {
  display: grid;
  /* grid-template-columns set inline from state */
  height: calc(100vh - 64px); /* topbar (~64px) */
  min-height: 640px;
  box-sizing: border-box;
  /* Deutlich dunklerer Workspace-Ton (theme-unabhängig), damit die
     weiße Preview-Box optisch klar hervortritt. */
  background: var(--mp-ink-300);
}

/* Center stage — extra padding so the preview "floats" away from the
   sidebar/inspector edges (≈ +10 px gegenüber Builder v1). */
.bd-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 26px;
}

/* ---- Upload help card ---- */
.bd-upload {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--mp-white);
  border: 2px dashed var(--mp-border-strong);
  border-radius: var(--mp-radius-md);
  padding: var(--mp-space-8) var(--mp-space-7);
  min-height: 360px;
}
.bd-upload__icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--mp-primary) 12%, transparent);
  color: var(--mp-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--mp-space-4);
}
.bd-upload__icon i[data-lucide] { width: 26px; height: 26px; }
.bd-upload__err {
  margin-top: var(--mp-space-4);
  padding: var(--mp-space-3) var(--mp-space-4);
  border: 1px solid var(--mp-danger);
  border-radius: var(--mp-radius-sm);
  background: color-mix(in srgb, var(--mp-danger) 8%, transparent);
  color: var(--mp-danger);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: var(--mp-space-2);
}
.bd-upload__err i[data-lucide] { width: 16px; height: 16px; }
.bd-upload__details {
  margin-top: var(--mp-space-5);
  width: 100%;
  max-width: 640px;
  text-align: left;
}
.bd-upload__details summary {
  font-size: 13px;
  font-weight: 700;
  color: var(--mp-fg);
  cursor: pointer;
  padding: var(--mp-space-2) 0;
}
.bd-upload__pre {
  background: var(--mp-bg-soft);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  padding: var(--mp-space-4);
  margin: var(--mp-space-3) 0 0;
  font-family: var(--mp-font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--mp-fg);
  white-space: pre;
  overflow-x: auto;
}

/* ---- Left menu (docked, flush to viewport edge, resizable) ---- */
.bd-menu {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--mp-white);
  border-right: 1px solid var(--mp-border);
  overflow: hidden;
  min-height: 0;
}
.bd-menu__head {
  padding: var(--mp-space-3) var(--mp-space-4);
  border-bottom: 1px solid var(--mp-border);
  background: var(--mp-bg-soft);
  flex-shrink: 0;
}
.bd-menu__headRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--mp-space-3);
}
.bd-menu__headLabel { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bd-menu__headTools { display: flex; gap: 4px; flex-shrink: 0; }
.bd-menu__iconBtn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mp-white);
  border: 1px solid var(--mp-border-strong);
  border-radius: var(--mp-radius-sm);
  color: var(--mp-fg-muted);
  cursor: pointer;
  transition: border-color var(--mp-duration-fast), color var(--mp-duration-fast), background var(--mp-duration-fast);
}
.bd-menu__iconBtn:hover {
  border-color: var(--mp-fg);
  color: var(--mp-fg);
  background: var(--mp-white);
}
.bd-menu__head strong { font-size: 14px; font-weight: 900; color: var(--mp-fg); letter-spacing: -0.005em; }
.bd-menu__sub {
  font-size: 11px;
  font-family: var(--mp-font-mono);
  color: var(--mp-fg-muted);
}
.bd-menu__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--mp-space-2);
  min-height: 0;
}

/* Column resize handle — 4px hit-area sits at the column edge, hover
   reveals a 2px primary bar. During drag the iframe's pointer-events
   are turned off (in JS) so mousemoves keep reaching the parent. */
.bd-resize {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  z-index: 5;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background var(--mp-duration-fast);
}
.bd-resize--right { right: -3px; }
.bd-resize--left  { left:  -3px; }
.bd-resize:hover { background: color-mix(in srgb, var(--mp-primary) 10%, transparent); }
.bd-resize__grip {
  width: 2px;
  height: 32px;
  border-radius: 999px;
  background: var(--mp-border-strong);
  transition: background var(--mp-duration-fast), height var(--mp-duration-fast);
}
.bd-resize:hover .bd-resize__grip { background: var(--mp-primary); height: 64px; }

.bd-group { margin-bottom: var(--mp-space-2); }
.bd-group__head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--mp-space-2);
  padding: var(--mp-space-2) var(--mp-space-3);
  background: transparent;
  border: 0;
  border-radius: var(--mp-radius-sm);
  font: 700 12px var(--mp-font-sans);
  color: var(--mp-fg);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: var(--mp-tracking-caps);
}
.bd-group__head:hover { background: var(--mp-bg-soft); }
.bd-group__head > span:nth-child(2) { flex: 1; text-align: left; }
.bd-group__count {
  font-family: var(--mp-font-mono);
  font-size: 11px;
  color: var(--mp-fg-subtle);
  padding: 2px 6px;
  background: var(--mp-bg-soft);
  border-radius: var(--mp-radius-pill);
  text-transform: none;
  letter-spacing: 0;
}
.bd-group__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 var(--mp-space-2);
}
.bd-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--mp-space-2) var(--mp-space-3);
  background: var(--mp-bg-soft);
  border: 1px solid transparent;
  border-radius: var(--mp-radius-sm);
  cursor: grab;
  text-align: left;
  position: relative;
  transition: border-color var(--mp-duration-fast), background var(--mp-duration-fast);
  font-family: var(--mp-font-sans);
  color: inherit;
}
.bd-card:hover {
  border-color: var(--mp-border-strong);
  background: var(--mp-white);
}
.bd-card:active { cursor: grabbing; }
.bd-card[draggable=false] { cursor: not-allowed; opacity: 0.55; }
.bd-card__name { font-size: 13px; font-weight: 700; color: var(--mp-fg); }
.bd-card__desc { font-size: 11px; color: var(--mp-fg-muted); line-height: 1.35; }
.bd-card__badge {
  position: absolute;
  top: 6px; right: 8px;
  font-size: 9px;
  font-family: var(--mp-font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--mp-primary);
}

/* ---- Center preview ---- */
.bd-preview {
  display: flex;
  flex: 1;
  flex-direction: column;
  background: var(--mp-white);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-md);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  width: 100%;
  margin: 0 auto;
  box-shadow: var(--mp-shadow-md);
  transition: max-width var(--mp-duration-base) var(--mp-ease-standard);
}
.bd-preview--desktop { max-width: none; }
.bd-preview--tablet  { max-width: 820px; }
.bd-preview--mobile  { max-width: 420px; }
/* Fullscreen overrides viewport sizing entirely */
.bd-preview.is-fullscreen { max-width: none !important; margin: 0; }
.bd-preview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--mp-space-2) var(--mp-space-4);
  border-bottom: 1px solid var(--mp-border);
  background: var(--mp-bg-soft);
  color: var(--mp-fg-muted);
}
.bd-iframe {
  flex: 1;
  border: 0;
  background: var(--mp-white);
  min-height: 0;
  width: 100%;
  transition: box-shadow var(--mp-duration-fast);
}
.bd-iframe.is-drop-target {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--mp-primary) 60%, transparent);
}

/* ---- Fullscreen preview overlay ---- */
.bd-preview.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  border-radius: 0;
  border: 0;
  background: var(--mp-white);
  animation: bd-preview-fade .14s ease;
}
.bd-preview.is-fullscreen .bd-preview__bar { display: none; }
@keyframes bd-preview-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.bd-preview__close {
  position: fixed;
  bottom: var(--mp-space-5);
  right: var(--mp-space-5);
  z-index: 1;
  height: 44px;
  padding: 0 var(--mp-space-4);
  display: inline-flex;
  align-items: center;
  gap: var(--mp-space-2);
  border-radius: 999px;
  border: 0;
  background: rgba(10, 21, 48, 0.78);
  color: var(--mp-white);
  font: 700 13px var(--mp-font-sans);
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: var(--mp-shadow-lg);
  transition: background var(--mp-duration-fast), transform var(--mp-duration-fast);
}
.bd-preview__close:hover { background: rgba(10, 21, 48, 0.92); transform: translateY(-1px); }
.bd-preview__close kbd {
  font-family: var(--mp-font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
}
.bd-preview__err {
  display: flex;
  align-items: flex-start;
  gap: var(--mp-space-3);
  padding: var(--mp-space-3) var(--mp-space-4);
  background: color-mix(in srgb, var(--mp-danger) 10%, var(--mp-white));
  border-bottom: 1px solid color-mix(in srgb, var(--mp-danger) 40%, transparent);
  color: var(--mp-fg);
}
.bd-preview__err > i[data-lucide] {
  width: 18px; height: 18px;
  color: var(--mp-danger);
  flex-shrink: 0;
  margin-top: 1px;
}
.bd-preview__err > div { flex: 1; min-width: 0; }
.bd-preview__err strong { font-size: 13px; font-weight: 700; color: var(--mp-danger); }
.bd-preview__err button { color: var(--mp-fg-muted); flex-shrink: 0; padding: 0 var(--mp-space-2); height: 28px; }
.bd-preview__err button i[data-lucide] { width: 14px; height: 14px; }

/* ---- Right inspector ---- */
.bd-inspector {
  position: relative;
  background: var(--mp-white);
  border-left: 1px solid var(--mp-border);
  overflow-y: auto;
  min-height: 0;
}
.bd-inspector__empty {
  padding: var(--mp-space-5);
  text-align: center;
  color: var(--mp-fg-muted);
  font-size: 13px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--mp-space-3);
}
.bd-inspector__empty i[data-lucide] {
  width: 28px; height: 28px;
  color: var(--mp-fg-subtle);
}
.bd-inspector__empty strong {
  color: var(--mp-fg);
  font-size: 14px;
  font-weight: 700;
}

.bd-insp { padding: var(--mp-space-4); display: flex; flex-direction: column; gap: var(--mp-space-4); }
.bd-insp__head {
  padding-bottom: var(--mp-space-4);
  border-bottom: 1px solid var(--mp-border);
}
.bd-insp__section {
  display: flex;
  flex-direction: column;
  gap: var(--mp-space-2);
}
.bd-insp__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: var(--mp-tracking-caps);
  text-transform: uppercase;
  color: var(--mp-fg-subtle);
}
.bd-insp__variants { display: flex; flex-direction: column; gap: 4px; }
.bd-variant {
  display: flex;
  align-items: flex-start;
  gap: var(--mp-space-3);
  padding: var(--mp-space-2) var(--mp-space-3);
  background: var(--mp-bg-soft);
  border: 1px solid transparent;
  border-radius: var(--mp-radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: var(--mp-font-sans);
  color: inherit;
  width: 100%;
}
.bd-variant:hover { border-color: var(--mp-border-strong); }
.bd-variant.is-active { background: color-mix(in srgb, var(--mp-primary) 6%, var(--mp-white)); border-color: var(--mp-primary); }
.bd-variant__dot {
  width: 12px; height: 12px;
  border-radius: 999px;
  border: 2px solid var(--mp-border-strong);
  background: var(--mp-white);
  flex-shrink: 0;
  margin-top: 2px;
  transition: border-color var(--mp-duration-fast);
}
.bd-variant.is-active .bd-variant__dot {
  border-color: var(--mp-primary);
  background: var(--mp-primary);
  box-shadow: inset 0 0 0 2px var(--mp-white);
}
.bd-insp__meta { font-size: 11px; }
.bd-insp__meta > div { display: flex; justify-content: space-between; padding: 4px 0; border-top: 1px solid var(--mp-border); }
.bd-insp__meta dt { color: var(--mp-fg-subtle); font-family: var(--mp-font-mono); margin: 0; }
.bd-insp__meta dd { color: var(--mp-fg); font-family: var(--mp-font-mono); margin: 0; }

/* ---- Inspector slot list ---- */
.bd-insp__slots { display: flex; flex-direction: column; gap: var(--mp-space-3); }
.bd-slot {
  background: var(--mp-bg-soft);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  padding: var(--mp-space-2) var(--mp-space-3);
}
.bd-slot__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--mp-space-2);
}
.bd-slot__name { font-size: 13px; font-weight: 700; color: var(--mp-fg); }
.bd-slot__status { font-size: 11px; color: var(--mp-fg-muted); margin-top: 2px; }
.bd-slot__list { list-style: none; padding: 0; margin: var(--mp-space-2) 0 0; display: flex; flex-direction: column; gap: 4px; }
.bd-slot__child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: var(--mp-space-2);
  background: var(--mp-white);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: var(--mp-font-sans);
}
.bd-slot__child:hover { border-color: var(--mp-border-strong); }
.bd-slot__childName { font-size: 12px; font-weight: 700; color: var(--mp-fg); }
.bd-slot__childComp { font-size: 10px; font-family: var(--mp-font-mono); color: var(--mp-fg-muted); letter-spacing: 0.04em; text-transform: uppercase; }
