/* Component anatomy stays inside its requested root; the canvas never adds a card. */
.component-preview {
  --cp-accent: #9b87ff; --cp-on-accent: #fff; --cp-bg: #19191f; --cp-field: #202027;
  --cp-text: #f1f0f5; --cp-muted: #b4b0bf; --cp-line: #48444f; --cp-radius: 10px;
  --cp-danger: #db3549; --cp-focus: #c3b8ff;
  min-height: 320px; padding: 40px 24px; background: transparent;
  color: var(--cp-text); font: 14px/1.5 var(--font-ui, system-ui, sans-serif); box-sizing: border-box;
}
.component-preview.ds-ant { --cp-accent: #1677ff; --cp-radius: 6px; --cp-bg: #141414; --cp-field: #1f1f1f; --cp-line: #505050; --cp-focus: #69b1ff; }
.component-preview.ds-material { --cp-accent: #90caf9; --cp-on-accent: #101a22; --cp-radius: 4px; --cp-bg: #212121; --cp-field: #292929; --cp-line: #777; --cp-focus: #90caf9; }
.component-preview.ds-connected { --cp-accent: #67d4de; --cp-on-accent: #082024; --cp-radius: 12px; }
[data-theme="light"] .component-preview { --cp-bg: #fff; --cp-field: #fff; --cp-text: #22212b; --cp-muted: #615d6e; --cp-line: #a5a1ae; --cp-accent: #6a46d6; --cp-focus: #6340c5; }
[data-theme="light"] .component-preview.ds-ant { --cp-accent: #1677ff; --cp-focus: #0958d9; }
[data-theme="light"] .component-preview.ds-material { --cp-accent: #1565c0; --cp-on-accent: #fff; --cp-focus: #1565c0; }
[data-theme="light"] .component-preview.ds-connected { --cp-accent: #067783; --cp-on-accent: #fff; --cp-focus: #067783; }
.component-preview *, .component-preview *::before, .component-preview *::after { box-sizing: border-box; }
.component-preview .cp-canvas { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; min-width: 0; }
.component-preview .cp-node { max-width: 100%; margin: 0; font-family: inherit; overflow-wrap: anywhere; }
.component-preview button, .component-preview input, .component-preview textarea, .component-preview select { font: inherit; }
.component-preview button { min-height: 40px; padding: 8px 16px; border: 1px solid var(--cp-line); border-radius: var(--cp-radius); color: var(--cp-text); background: var(--cp-field); cursor: pointer; }
.component-preview button:hover:not(:disabled) { filter: brightness(1.12); }
.component-preview :is(button, input, textarea, select, summary, a):focus-visible { outline: 3px solid var(--cp-focus); outline-offset: 3px; }
.component-preview :disabled { opacity: .48; cursor: not-allowed; }
.component-preview .cp-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--cp-accent); color: var(--cp-on-accent); border-color: transparent; font-weight: 600; }
.component-preview .cp-button[data-variant="secondary"] { background: transparent; color: var(--cp-accent); border-color: var(--cp-accent); }
.component-preview .cp-button[data-variant="danger"] { background: var(--cp-danger); color: #fff; }
.component-preview.ds-material .cp-button { text-transform: uppercase; font-weight: 500; letter-spacing: .04em; box-shadow: 0 2px 4px #0004; }
.component-preview :is(.cp-input,.cp-textarea,.cp-select,.cp-datepicker,.cp-upload,.cp-slider,.cp-progress) { display: grid; gap: 7px; width: 300px; }
.component-preview :is(.cp-input,.cp-textarea,.cp-select,.cp-datepicker,.cp-upload) > label { font-size: 13px; color: var(--cp-muted); }
.component-preview :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select) { width: 100%; min-width: 0; min-height: 40px; padding: 9px 12px; border: 1px solid var(--cp-line); border-radius: var(--cp-radius); color: var(--cp-text); background: var(--cp-field); color-scheme: dark; }
[data-theme="light"] .component-preview :is(input, textarea, select) { color-scheme: light; }
.component-preview input::placeholder, .component-preview textarea::placeholder { color: var(--cp-muted); }
.component-preview textarea { resize: vertical; }
.component-preview.ds-material :is(.cp-input,.cp-textarea,.cp-select,.cp-datepicker) { gap: 0; position: relative; padding-top: 8px; }
.component-preview.ds-material :is(.cp-input,.cp-textarea,.cp-select,.cp-datepicker) > label { position: relative; align-self: start; justify-self: start; z-index: 1; top: 8px; margin: -8px 0 0 10px; padding: 0 4px; background: var(--cp-bg); font-size: 12px; }
.component-preview.ds-material :is(.cp-input,.cp-textarea,.cp-select,.cp-datepicker) > :is(input,textarea,select) { min-height: 50px; padding-top: 12px; }
.component-preview :is(.cp-checkbox,.cp-switch) { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.component-preview input[type="checkbox"], .component-preview input[type="radio"] { width: 18px; height: 18px; margin: 0; accent-color: var(--cp-accent); cursor: pointer; }
.component-preview .cp-switch input { appearance: none; flex: 0 0 40px; width: 40px; height: 24px; border-radius: 20px; background: var(--cp-line); position: relative; transition: background .15s; }
.component-preview .cp-switch input::after { content: ''; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: #fff; transition: transform .15s; }
.component-preview .cp-switch input:checked { background: var(--cp-accent); }
.component-preview .cp-switch input:checked::after { transform: translateX(16px); }
.component-preview.ds-material .cp-switch input { height: 16px; }
.component-preview.ds-material .cp-switch input::after { width: 22px; height: 22px; top: -3px; left: 0; box-shadow: 0 1px 4px #0007; }
.component-preview .cp-radio { border: 0; padding: 0; display: grid; gap: 9px; }
.component-preview .cp-radio legend { margin-bottom: 8px; }
.component-preview .cp-radio label { display: flex; align-items: center; gap: 9px; }
.component-preview .cp-slider input { width: 100%; accent-color: var(--cp-accent); }
.component-preview .cp-slider output { color: var(--cp-muted); text-align: right; }
.component-preview :is(.cp-card,.cp-surface,.cp-form,.cp-layout,.cp-dialog) { display: flex; flex-direction: column; align-items: stretch; gap: 18px; width: 360px; min-height: 120px; padding: 24px; position: relative; }
.component-preview :is(.cp-card,.cp-surface,.cp-dialog) { border: 1px solid var(--cp-line); border-radius: var(--cp-radius); background: var(--cp-bg); }
.component-preview .cp-form { padding: 0; }
.component-preview .cp-layout { width: 560px; padding: 12px; }
.component-preview :is(.cp-form,.cp-layout):empty { border: 1px dashed var(--cp-line); }
.component-preview [data-direction="row"] { flex-direction: row; flex-wrap: wrap; align-items: center; }
.component-preview .cp-dialog { width: 460px; box-shadow: 0 14px 40px #0003; }
.component-preview.ds-material :is(.cp-card,.cp-surface) { box-shadow: 0 4px 10px #0003; }
.component-preview h3 { margin: 0; font-size: 18px; font-weight: 600; }
.component-preview p { margin: 0; }
.component-preview .cp-close { position: absolute; right: 6px; top: 6px; background: transparent; padding: 4px; border: 0; min-height: 32px; min-width: 32px; }
.component-preview .cp-alert { display: flex; align-items: flex-start; gap: 10px; width: 360px; border: 1px solid var(--cp-accent); border-radius: var(--cp-radius); padding: 14px 16px; background: color-mix(in srgb, var(--cp-accent) 12%, var(--cp-bg)); }
.component-preview .cp-alert[data-tone="error"] { border-color: #e06470; }
.component-preview .cp-alert[data-tone="warning"] { border-color: #c68c2c; }
.component-preview .cp-alert[data-tone="success"] { border-color: #46a87e; }
.component-preview .cp-alert-mark { font-weight: 800; border: 1px solid currentColor; border-radius: 50%; line-height: 18px; width: 20px; text-align: center; flex-shrink: 0; }
.component-preview .cp-alert p { color: var(--cp-muted); margin-top: 4px; }
.component-preview .cp-badge { padding: 3px 10px; border: 1px solid var(--cp-line); border-radius: 20px; font-size: 12px; background: var(--cp-field); }
.component-preview.ds-ant .cp-badge { border-radius: 4px; }
.component-preview .cp-avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--cp-accent); color: var(--cp-on-accent); font-size: 18px; font-weight: 600; }
.component-preview .cp-avatar svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.component-preview .cp-list { width: 320px; padding: 0; list-style: none; }
.component-preview .cp-list:empty { min-height: 40px; border-bottom: 1px solid var(--cp-line); }
.component-preview .cp-list li { padding: 12px 0; border-bottom: 1px solid var(--cp-line); }
.component-preview .cp-table { width: 520px; overflow-x: auto; }
.component-preview table { width: 100%; border-collapse: collapse; font: inherit; }
.component-preview :is(th,td) { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--cp-line); }
.component-preview th { background: var(--cp-field); font-weight: 600; }
.component-preview td { color: var(--cp-muted); }
.component-preview caption { text-align: left; margin-bottom: 10px; }
.component-preview .cp-tabs { width: 420px; }
.component-preview [role="tablist"] { display: flex; overflow-x: auto; border-bottom: 1px solid var(--cp-line); }
.component-preview [role="tab"] { flex-shrink: 0; background: transparent; border: 0; border-radius: 0; border-bottom: 2px solid transparent; }
.component-preview [role="tab"][aria-selected="true"] { color: var(--cp-accent); border-bottom-color: var(--cp-accent); }
.component-preview [role="tabpanel"] { padding: 16px 0; min-height: 42px; }
.component-preview .cp-accordion { width: 360px; border: 1px solid var(--cp-line); border-radius: var(--cp-radius); }
.component-preview summary { padding: 12px 16px; cursor: pointer; }
.component-preview details > div { padding: 0 16px 16px; }
.component-preview progress { width: 100%; height: 10px; accent-color: var(--cp-accent); }
.component-preview .cp-progress > span { color: var(--cp-muted); font-size: 12px; }
.component-preview .cp-spinner-ring,.component-preview .cp-loading-dot { display: inline-block; width: 30px; height: 30px; border: 3px solid var(--cp-line); border-top-color: var(--cp-accent); border-radius: 50%; animation: cp-spin .8s linear infinite; }
.component-preview .cp-loading-dot { width: 16px; height: 16px; border-width: 2px; border-color: currentColor transparent currentColor currentColor; }
.component-preview .cp-tooltip { position: relative; }
.component-preview [role="tooltip"] { position: absolute; z-index: 4; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 240px; padding: 8px 12px; border: 1px solid var(--cp-line); border-radius: 6px; background: var(--cp-bg); color: var(--cp-text); opacity: 0; pointer-events: none; }
.component-preview .cp-tooltip:hover [role="tooltip"], .component-preview .cp-tooltip:focus-within [role="tooltip"] { opacity: 1; }
.component-preview .cp-divider { width: 320px; border: 0; border-top: 1px solid var(--cp-line); }
.component-preview .cp-heading { font-size: 26px; line-height: 1.25; }
.component-preview .cp-image { display: grid; place-items: center; width: 320px; min-height: 180px; object-fit: contain; border: 1px dashed var(--cp-line); background: var(--cp-field); color: var(--cp-muted); }
.component-preview .cp-breadcrumb ol { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.component-preview .cp-breadcrumb li + li::before { content: '/'; margin-right: 10px; color: var(--cp-muted); }
.component-preview .cp-pagination { display: flex; gap: 8px; }
.component-preview .cp-pagination [aria-current] { border-color: var(--cp-accent); color: var(--cp-accent); }
.component-preview .cp-menu { display: grid; min-width: 180px; gap: 2px; }
.component-preview .cp-menu button { text-align: left; border: 0; background: transparent; }
.component-preview .cp-link { color: var(--cp-accent); text-decoration: underline; }
.component-preview .cp-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.component-preview .cp-skeleton { display: block; width: 240px; height: 24px; border-radius: var(--cp-radius); background: var(--cp-line); animation: cp-pulse 1.4s ease-in-out infinite alternate; }
.component-preview .cp-notice { max-width: 520px; margin: 24px auto 0; font-size: 13px; text-align: center; color: var(--cp-muted); }
.component-preview [hidden] { display: none !important; }
@keyframes cp-spin { to { transform: rotate(360deg); } }
@keyframes cp-pulse { to { opacity: .35; } }
@media (max-width: 600px) { .component-preview { padding: 24px 14px; } .component-preview :is(.cp-card,.cp-surface,.cp-dialog) { padding: 18px; } }
@media (prefers-reduced-motion: reduce) { .component-preview * { animation: none !important; transition: none !important; } }

.component-preview [data-runtime-tooltip]:not([hidden]) { opacity: 1; }
.component-preview .cp-runtime-feedback { padding: 12px; border: 1px solid var(--cp-line); border-radius: 8px; }
.component-preview [aria-busy="true"] { cursor: progress; opacity: .65; }
