html,
body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden !important;
}

body {
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

body.is-dragging-component,
body.is-dragging-component * {
    user-select: none !important;
    -webkit-user-select: none !important;
    cursor: grabbing !important;
}

body.is-panning,
body.is-panning * {
    cursor: grabbing !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.ant-btn {
    display: inline-flex;
    height: 32px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 8px;
    border: 1px solid #d9d9d9;
    background: #fff;
    padding: 4px 15px;
    color: rgba(0, 0, 0, 0.88);
    font-size: 14px;
    line-height: 22px;
    transition:
        color 0.2s,
        border-color 0.2s,
        background 0.2s,
        box-shadow 0.2s;
}

.ant-btn:hover {
    border-color: #4096ff;
    color: #1677ff;
}

.ant-btn-primary {
    border-color: #1677ff;
    background: #1677ff;
    color: #fff;
    box-shadow: 0 2px 0 rgba(5, 145, 255, 0.1);
}

.ant-btn-primary:hover {
    border-color: #4096ff;
    background: #4096ff;
    color: #fff;
}

.ant-btn-small {
    height: 28px;
    padding: 2px 10px;
    font-size: 12px;
}

.icon-btn {
    display: inline-flex;
    height: 32px;
    width: 32px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid #d9d9d9;
    background: #fff;
    color: rgba(0, 0, 0, 0.65);
    transition:
        color 0.2s,
        border-color 0.2s,
        background 0.2s;
    cursor: pointer !important;
}

.icon-btn:hover {
    border-color: #4096ff;
    color: #1677ff;
}

.icon-btn.danger {
    border-color: #ffccc7;
    background: #fff2f0;
    color: #ff4d4f;
}

.icon-btn.danger:hover {
    border-color: #ff4d4f;
    background: #ff4d4f;
    color: #fff;
}

.code-badge {
    display: inline-flex;
    min-width: 24px;
    height: 22px;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.04);
    padding: 0 8px;
    color: rgba(0, 0, 0, 0.65);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    line-height: 20px;
}

.component-copy {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
}

.component-copy strong {
    color: #1e293b;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.canvas-grid {
    background-color: #f1f3f4;
    background-image: radial-gradient(rgba(0, 0, 0, 0.08) 1.5px, transparent 1.5px);
    background-size: 24px 24px;
}

.canvas-grid {
    --canvas-x: 320px;
    --canvas-y: 160px;
    --canvas-scale: 1;
    cursor: grab;
    overflow: hidden !important;
}

.canvas-grid:active {
    cursor: grabbing;
}

body.space-panning-ready,
body.space-panning-ready * {
    cursor: grab !important;
}

.canvas-world {
    position: absolute;
    left: 0;
    top: 0;
    width: 390px;
    min-height: 720px;
    transform: translate(var(--canvas-x), var(--canvas-y)) scale(var(--canvas-scale));
    transform-origin: 0 0;
}

.canvas-world.is-zooming {
    transition: transform 0.35s cubic-bezier(0.2, 0, 0, 1);
}

.mobile-frame {
    cursor: grab;
    transition:
        box-shadow 0.2s,
        border-color 0.2s;
    position: absolute;
    transform-origin: 0 0;
}

/* SVG连线路径样式 */
.connection-path {
    fill: none;
    stroke: #cbd5e1; /* slate-300, 更加轻量级 */
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: stroke;
    transition:
        stroke 0.3s ease,
        stroke-width 0.3s ease;
    marker-end: url(#arrowhead);
}

.connection-path:hover {
    stroke: #94a3b8; /* slate-400, 悬停时仅微微加深，不再突兀 */
    stroke-width: 3;
}

.connection-arrowhead {
    transition: fill 0.3s ease;
}

.connection-path:hover ~ * .connection-arrowhead, /* When path is hovered, we want the marker to change color. But markers are defined in defs. SVG markers inherit styles from the path! So if path stroke changes, does marker inherit? We'll use CSS stroke for path and fill context-stroke for marker if supported, else just set marker fill via path's currentColor... Actually the easiest way to make marker inherit path color is to use fill="context-stroke" (in some browsers) or just accept it's grey. Let's try stroke context. */
.connection-path {
    /* To make marker inherit path color */
}

.connection-path.is-temp {
    stroke: #3b82f6;
    stroke-dasharray: 6 4;
}

.canvas-connection-path {
    fill: none;
    stroke: #cbd5e1;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke 0.3s;
}

.canvas-connection-path:hover {
    stroke: #1677ff;
}

.mobile-frame:active {
    cursor: grabbing;
}

button {
    cursor: pointer;
}
.ruler-corner {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 30;
    width: 20px;
    height: 20px;
    background: #f8fafc;
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.ruler {
    position: absolute;
    z-index: 25;
    background: #f8fafc;
    user-select: none;
    pointer-events: none;
}

.ruler-top {
    top: 0;
    left: 20px;
    height: 20px;
    width: calc(100% - 20px);
    border-bottom: 1px solid #e5e7eb;
}

.ruler-left {
    left: 0;
    top: 20px;
    width: 20px;
    height: calc(100% - 20px);
    border-right: 1px solid #e5e7eb;
}

.empty-state,
.prop-empty {
    display: flex;
    min-height: 300px;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: rgba(0, 0, 0, 0.45);
}

.empty-state {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.prop-empty.hidden {
    display: none !important;
}

.canvas-dropzone.has-elements {
    border-color: transparent;
}

.canvas-dropzone.is-dragging {
    border-color: #1677ff;
    background: linear-gradient(135deg, rgba(22, 119, 255, 0.08), rgba(19, 194, 194, 0.06)), #f7fbff;
    box-shadow: inset 0 0 0 2px rgba(22, 119, 255, 0.08);
}

.canvas-dropzone.is-dragging .empty-state {
    display: none !important;
}

.canvas-element {
    position: relative;
    margin-bottom: 12px;
    cursor: pointer;
    border-radius: 12px;
    border: 1px solid transparent;
    background: #fff;
    padding: 16px;
    box-shadow:
        0 2px 4px rgba(15, 23, 42, 0.03),
        0 0 0 1px rgba(15, 23, 42, 0.05);
    transition:
        box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.canvas-element:hover {
    box-shadow:
        0 8px 16px -4px rgba(15, 23, 42, 0.06),
        0 0 0 1px rgba(59, 130, 246, 0.4);
}

.canvas-element.is-selected {
    box-shadow:
        0 8px 24px -4px rgba(59, 130, 246, 0.15),
        0 0 0 2px #3b82f6;
    z-index: 10;
}

.canvas-element input,
.canvas-element textarea,
.canvas-element select,
.canvas-element label:not(.element-actions label),
.canvas-element span:not(.element-actions span),
.canvas-element p,
.canvas-element .choice-group,
.canvas-element .choice-group * {
    pointer-events: none;
}

.canvas-element .label-text,
.canvas-element .option-text,
.canvas-element .signature-declaration-text {
    pointer-events: auto !important;
    cursor: text !important;
    transition: color 0.2s;
}

body.is-dragging-component .canvas-element .label-text,
body.is-dragging-component .canvas-element .option-text,
body.is-dragging-component .canvas-element .signature-declaration-text {
    pointer-events: none !important;
    cursor: grabbing !important;
}

.canvas-element .label-text:hover,
.canvas-element .option-text:hover,
.canvas-element .signature-declaration-text:hover {
    color: #1677ff;
}

body.is-dragging-component .canvas-element .label-text:hover,
body.is-dragging-component .canvas-element .option-text:hover,
body.is-dragging-component .canvas-element .signature-declaration-text:hover {
    color: inherit;
}

.canvas-text-focus {
    display: inline-block;
    color: #1677ff;
    box-shadow: 0 2px 0 0 #1677ff;
    transition:
        color 0.2s,
        box-shadow 0.2s;
}

.canvas-control-focus {
    border-color: #1677ff !important;
    background: #fff !important;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.15) !important;
}

.layout-element {
    border-style: dashed;
    border-color: #cbd5e1;
}

.component-label {
    display: block;
    margin-bottom: 7px;
    color: rgba(0, 0, 0, 0.88);
    font-weight: 500;
    line-height: 22px;
}

.component-label::before {
    content: none;
}

.req-star {
    color: #ff4d4f;
}

.ant-input,
.component-placeholder,
.preview-input {
    min-height: 36px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 6px 12px;
    color: rgba(0, 0, 0, 0.88);
    font-size: 13px;
    line-height: 1.5715;
    outline: 0;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.ant-input:focus,
.preview-input:focus {
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.component-placeholder:disabled {
    cursor: not-allowed;
    background: #fafafa;
    color: rgba(0, 0, 0, 0.65);
}

textarea.ant-input,
textarea.component-placeholder,
textarea.preview-input {
    resize: vertical;
    line-height: 22px;
}

.choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
}

.choice-group.choice-stack {
    flex-direction: column;
    gap: 10px;
}

.choice-group label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(0, 0, 0, 0.65);
}

.field-help {
    margin: 8px 0 0;
    color: rgba(0, 0, 0, 0.45);
    font-size: 12px;
    line-height: 20px;
}

.element-actions {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 10;
    display: none;
    gap: 6px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.canvas-element:hover > .element-actions,
.canvas-element.is-selected > .element-actions {
    display: flex;
}

.element-actions .icon-btn {
    height: 20px;
    width: 20px;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 4px;
    transition: all 0.2s;
}

.element-actions .icon-btn svg {
    width: 14px;
    height: 14px;
}

.element-actions .icon-btn:hover {
    background: #f1f5f9;
    color: #1677ff;
}

.element-actions .icon-btn.danger:hover {
    background: #fee2e2;
    color: #ef4444;
}

.grid-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.nested-dropzone {
    position: relative;
    min-height: 96px;
    border-radius: 12px;
    border: 1.5px dashed #cbd5e1;
    background: #f8fafc;
    padding: 12px;
    transition:
        border-color 0.2s,
        background 0.2s,
        box-shadow 0.2s;
}

.nested-dropzone:hover {
    border-color: #4096ff;
    background: #fbfdff;
    box-shadow: inset 0 0 0 1px rgba(22, 119, 255, 0.06);
}

.nested-dropzone .canvas-element {
    margin-bottom: 8px;
}

.empty-hint {
    position: absolute;
    inset: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.45);
    font-size: 12px;
    pointer-events: none;
}

.prop-section {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: transparent;
    padding: 20px 16px;
    flex-shrink: 0;
}

.prop-section:last-child {
    border-bottom: none;
}

.prop-section + .prop-section {
    margin-top: 0;
}

.section-title {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: rgba(0, 0, 0, 0.88);
    font-size: 13px;
    font-weight: 600;
}

.form-control {
    display: block;
}

.form-control + .form-control {
    margin-top: 12px;
}

.form-control > span {
    display: block;
    margin-bottom: 6px;
    color: rgba(0, 0, 0, 0.88);
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
}

.form-control .ant-input,
.form-control select,
.form-control textarea {
    font-size: 12px;
    min-height: 32px;
    padding: 4px 10px;
    border-radius: 6px;
}

.options-editor {
    display: flex;
    flex-direction: column;
    max-height: 300px;
    gap: 8px;
    overflow-y: auto;
    padding-right: 2px;
}

/* 极简选项面板使用 Tailwind 实用类，不再需要复杂的自定义 CSS */

#prop-options-group > p {
    border-radius: 6px;
    border: 1px solid #f0f0f0;
    background: #fafafa;
    padding: 6px 8px;
    color: rgba(0, 0, 0, 0.45);
    font-size: 11px;
    line-height: 18px;
}

.ant-switch {
    position: relative;
    display: inline-flex;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.ant-switch input {
    position: absolute;
    opacity: 0;
}

.ant-switch span {
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.25);
    transition: background 0.2s;
}

.ant-switch span::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.ant-switch input:checked + span {
    background: #1677ff;
}

.ant-switch input:checked + span::after {
    transform: translateX(18px);
}

.preview-field {
    border-radius: 8px;
    border: 1px solid #f0f0f0;
    background: #fff;
    padding: 16px;
}

.preview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

.preview-grid-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sortable-ghost,
.drop-placeholder {
    min-height: 64px !important;
    margin-bottom: 10px !important;
    opacity: 1 !important;
    border: 2px dashed #93c5fd !important;
    border-radius: 8px !important;

    background: #eff6ff !important;
    box-shadow: none !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    overflow: hidden;
    position: relative;
}

.component-item.sortable-ghost > * {
    display: none !important;
}

.sortable-ghost::before,
.drop-placeholder::before {
    content: "";
    display: block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v16M19 13l-7 7-7-7'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: dropSmooth 2.5s infinite ease-in-out;
}

@keyframes dropSmooth {
    0%,
    100% {
        transform: translateY(-3px);
        opacity: 0.6;
    }
    50% {
        transform: translateY(3px);
        opacity: 1;
    }
}

.sortable-ghost::after,
.drop-placeholder::after {
    content: "松开以放置组件";
    font-size: 13px;
    letter-spacing: 1px;
    color: #3b82f6;
    font-weight: 500;
}

.canvas-dropzone .canvas-element.sortable-ghost {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    background: #eff6ff !important;
    border: 2px dashed #93c5fd !important;
    box-shadow: none !important;
}

.canvas-dropzone .canvas-element.sortable-ghost::before,
.canvas-dropzone .canvas-element.sortable-ghost::after {
    display: none !important;
}

.canvas-dropzone .canvas-element.sortable-ghost > * {
    opacity: 0.4 !important;
    visibility: visible !important;
    pointer-events: none !important;
}

.canvas-dropzone .component-item.sortable-ghost {
    width: 100% !important;
    height: 88px !important;
    flex-direction: row !important;
    gap: 8px !important;
}

.canvas-dropzone .component-item[data-type="signature"].sortable-ghost {
    height: 201px !important;
}

.canvas-dropzone .component-item[data-type="textarea"].sortable-ghost {
    height: 127px !important;
}

.canvas-dropzone .component-item[data-type="grid"].sortable-ghost {
    height: 122px !important;
}

.canvas-dropzone .component-item[data-type="radio"].sortable-ghost,
.canvas-dropzone .component-item[data-type="checkbox"].sortable-ghost {
    height: 98px !important;
}

.canvas-dropzone .component-item.sortable-ghost > * {
    display: block !important;
    color: #3b82f6 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
}

.canvas-dropzone .component-item.sortable-ghost::before,
.canvas-dropzone .component-item.sortable-ghost::after {
    display: none !important;
}

#components-basic .sortable-ghost,
#components-business .sortable-ghost,
#components-layout .sortable-ghost {
    min-height: 0 !important;
    height: auto !important;
    margin-bottom: 0 !important;
    border: 1px dashed rgba(148, 163, 184, 0.4) !important;
    background: transparent !important;
    box-shadow: none !important;
}

#components-basic .sortable-ghost > *,
#components-business .sortable-ghost > *,
#components-layout .sortable-ghost > * {
    display: unset !important;
    visibility: hidden !important;
}

#components-basic .sortable-ghost::before,
#components-basic .sortable-ghost::after,
#components-business .sortable-ghost::before,
#components-business .sortable-ghost::after,
#components-layout .sortable-ghost::before,
#components-layout .sortable-ghost::after {
    display: none !important;
}

.sortable-drag {
    transition: none !important;
    cursor: grabbing !important;
    box-shadow:
        0 25px 50px -12px rgba(15, 23, 42, 0.25),
        0 0 0 2px #3b82f6 !important;
}

.drag-fallback {
    transition: none !important;
    pointer-events: none !important;
    box-shadow:
        0 25px 50px -12px rgba(15, 23, 42, 0.25),
        0 0 0 2px #3b82f6 !important;
    z-index: 9999 !important;
    opacity: 1 !important;
}

.drag-fallback-shell {
    overflow: visible !important;
    border: 0 !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    opacity: 1 !important;
}

.drag-fallback-visual {
    margin: 0 !important;
    transform-origin: 0 0 !important;
}

@keyframes highlightPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(22, 119, 255, 0.4);
        border-color: #1677ff;
        background-color: #e6f4ff;
    }
    50% {
        box-shadow: 0 0 0 4px rgba(22, 119, 255, 0);
        border-color: #1677ff;
        background-color: #fff;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(22, 119, 255, 0);
    }
}

.pulse-highlight {
    animation: highlightPulse 1.2s ease-out !important;
}

.drag-chosen {
    opacity: 0.8;
}

.runtime-error {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: 16px;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-radius: 8px;
    background: #ff4d4f;
    padding: 12px 16px;
    color: #fff;
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.08),
        0 9px 28px rgba(0, 0, 0, 0.12);
}

/* 提示区块无底层卡片样式，但保留标准选中发光特效 */
.canvas-element[data-type="alert"] {
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.canvas-element[data-type="alert"]:hover {
    box-shadow:
        0 8px 16px -4px rgba(15, 23, 42, 0.06),
        0 0 0 1px rgba(59, 130, 246, 0.4);
}

.canvas-element[data-type="alert"].is-selected {
    box-shadow:
        0 8px 24px -4px rgba(59, 130, 246, 0.15),
        0 0 0 2px #3b82f6;
}
