* {
    box-sizing: border-box;
}

:root {
    --bg-0: #eef3ff;
    --bg-1: #e5efff;
    --text-main: #12223d;
    --text-sub: #607399;
    --primary: #2d75ff;
    --primary-deep: #1f60dc;
    --line: #d8e4ff;
}

body {
    margin: 0;
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(circle at 14% 16%, rgba(125, 170, 255, 0.3), transparent 40%),
        radial-gradient(circle at 88% 4%, rgba(107, 211, 255, 0.26), transparent 35%),
        linear-gradient(135deg, var(--bg-0) 0%, var(--bg-1) 100%);
}

.page {
    max-width: 1380px;
    margin: 0 auto;
    padding: 22px 20px 28px;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.title {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-sub);
    letter-spacing: 0.2px;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, #4a94ff 100%);
    box-shadow: 0 8px 20px rgba(45, 117, 255, 0.32);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(45, 117, 255, 0.38);
    filter: brightness(1.02);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 16px rgba(45, 117, 255, 0.28);
}

.stage {
    position: relative;
    min-height: 780px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background-color: #ffffffbf;
    backdrop-filter: blur(6px);
    background-image:
        linear-gradient(to right, rgba(45, 117, 255, 0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(45, 117, 255, 0.1) 1px, transparent 1px);
    background-size: calc(100% / 12) 60px;
    box-shadow: 0 16px 40px rgba(29, 71, 150, 0.14);
    overflow: hidden;
    transition: box-shadow 0.26s ease, border-color 0.26s ease, background-color 0.26s ease;
}

.stage.operating {
    border-color: #bfd4ff;
    background-color: #ffffffd6;
    background-image:
        linear-gradient(to right, rgba(45, 117, 255, 0.18) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(45, 117, 255, 0.18) 1px, transparent 1px);
    box-shadow: 0 18px 46px rgba(29, 71, 150, 0.2);
}

.widget {
    position: absolute;
    background: #fff;
    border: 1px solid #d7e3ff;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(27, 63, 131, 0.1);
    overflow: hidden;
    user-select: none;
    will-change: left, top, width, height;
    transition: box-shadow 0.22s ease, border-color 0.22s ease;
}

.widget:hover {
    box-shadow: 0 12px 28px rgba(27, 63, 131, 0.16);
}

.widget.active {
    border-color: #7aa9ff;
    box-shadow: 0 14px 32px rgba(45, 117, 255, 0.22);
}

.widget-tools {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.widget:hover .widget-tools {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.drag-handle-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #cddcff;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.95);
    color: #4a71b0;
    cursor: grab;
    font-size: 14px;
    line-height: 1;
    box-shadow: 0 6px 14px rgba(31, 72, 148, 0.12);
}

.drag-handle-btn:active {
    cursor: grabbing;
}

.widget-actions button {
    border: 1px solid #d4e2ff;
    background: rgba(255, 255, 255, 0.96);
    color: #2d75ff;
    border-radius: 8px;
    padding: 4px 9px;
    margin-left: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.widget-actions button:hover {
    border-color: #b9d0ff;
    background: #f3f8ff;
}

.widget-actions .btn-ai {
    color: #6e4bff;
    border-color: #d9d0ff;
    background: rgba(244, 240, 255, 0.95);
}

.widget-actions .btn-ai:hover {
    border-color: #c1b0ff;
    background: #eee7ff;
}

.widget-body {
    height: 100%;
    padding: 10px;
    overflow: auto;
}

.resize-handle {
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 18px;
    height: 18px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 48%, var(--primary) 52%);
    border-bottom-right-radius: 9px;
    opacity: 0.85;
    z-index: 5;
}

.drag-ghost {
    position: absolute;
    border-radius: 14px;
    border: 1px dashed rgba(45, 117, 255, 0.95);
    background: rgba(45, 117, 255, 0.1);
    box-shadow: inset 0 0 0 1px rgba(45, 117, 255, 0.12);
    pointer-events: none;
    z-index: 6;
}

.align-line {
    position: absolute;
    pointer-events: none;
    z-index: 7;
}

.align-line-v {
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom, rgba(255, 120, 80, 0.92), rgba(255, 120, 80, 0.35));
}

.align-line-h {
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, rgba(255, 120, 80, 0.92), rgba(255, 120, 80, 0.35));
}

.panel-mask {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(9, 17, 30, 0.36);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    animation: maskFadeIn 0.2s ease;
}

.panel {
    width: 600px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 20px 52px rgba(17, 39, 81, 0.25);
    animation: panelIn 0.26s ease;
}

.panel h3 {
    margin: 0 0 14px;
    font-size: 18px;
}

.form-row {
    margin-bottom: 12px;
}

.form-row label {
    font-size: 13px;
    display: block;
    margin-bottom: 5px;
    color: #5f7296;
}

.input,
.select,
textarea {
    width: 100%;
    border: 1px solid #d6e4ff;
    border-radius: 9px;
    padding: 9px 11px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input:focus,
.select:focus,
textarea:focus {
    border-color: #9ebfff;
    box-shadow: 0 0 0 3px rgba(45, 117, 255, 0.13);
}

.panel-footer {
    text-align: right;
    margin-top: 14px;
}

.ai-explain-text {
    line-height: 1.8;
    color: #31415e;
    font-size: 14px;
    background: #f7f9ff;
    border: 1px solid #e2e9ff;
    border-radius: 10px;
    padding: 12px;
    white-space: pre-wrap;
}

.btn-lite {
    background: #ecf3ff;
    color: var(--primary-deep);
    box-shadow: none;
    margin-right: 8px;
}

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

.component-item {
    border: 1px solid #d5e3fb;
    border-radius: 9px;
    padding: 11px;
    cursor: pointer;
    font-size: 13px;
    color: #3b5b86;
    background: #f8fbff;
    text-align: center;
    transition: all 0.18s ease;
}

.component-item:hover {
    transform: translateY(-1px);
    border-color: #b8d1ff;
    background: #f1f7ff;
}

.component-item.active {
    border-color: var(--primary);
    background: #eaf3ff;
    color: var(--primary-deep);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(45, 117, 255, 0.16);
}

body.is-dragging-widget,
body.is-dragging-widget * {
    cursor: grabbing !important;
}

@keyframes maskFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes panelIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
 