* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.editor {
    display: flex;
    gap: 30px;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 500;
    font-size: 14px;
}

input[type="text"],
select {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

input[type="range"] {
    width: 100%;
}

button {
    padding: 12px 20px;
    background: #ff2442;
    /* 小红书配色 */
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

button:hover {
    background: #e81f3d;
}

.preview-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-container {
    border: 4px solid #000000;
    padding: 5px;
    border-radius: 4px;
    width: 424px;
    /* 414 + 10 (padding) */
    height: 906px;
    /* 896 + 10 (padding) */
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

#preview {
    position: relative;
    width: 414px;
    height: 896px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

/* 文字区域 - 居中显示 */
#textOverlay {
    width: 100%;
    padding: 60px 20px 0px;
    /* 将padding-top从30px改为60px */
    font-size: 30px;
    font-weight: bold;
    text-align: center;
    /* 改为居中对齐 */
    line-height: 1.2;
    margin-bottom: 0;
}

/* 手机容器 */
.phone-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 改为居中对齐 */
}

/* 手机框架 */
.phone-frame {
    position: relative;
    /* 改回相对定位 */
    width: auto;
    /* 自动宽度 */
    height: 120%;
    /* 调整高度 */
    display: flex;
    justify-content: center;
    align-items: center;
    bottom: auto;
    /* 取消底部定位 */
    transform: translateY(7%);
    /* 微调位置 */
}

/* 手机图像 */
#phoneFrame {
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    position: relative;
    z-index: 2;
    display: block;
    /* 确保显示 */
    visibility: visible;
    /* 确保可见 */
}

/* 屏幕区域 - 添加更明显的圆角以匹配iPhone设计 */
.screen {
    position: absolute;
    top: 4%;
    /* 从4%改为6%，让截图向下移动 */
    left: 8%;
    width: 84%;
    height: 88%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    overflow: hidden;
    border-radius: 20px;
    background-color: white;
}

/* 去掉伪元素的白色背景，它可能挡住了截图 */
.screen::before {
    content: none;
    /* 移除伪元素 */
}

/* 截图预览 - 确保内容也遵循圆角 */
#screenshotPreview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* 改为contain，完整显示图片 */
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s;
    background-color: white;
    border-radius: 20px;
    /* 为图片也添加相同的圆角 */
}

/* 当有src属性时才显示 */
#screenshotPreview[src]:not([src=""]):not([src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"]) {
    opacity: 1;
}

/* 移动端适配样式 */
@media (max-width: 768px) {
    .editor {
        flex-direction: column;
        /* 改为纵向排列 */
        padding: 20px;
        gap: 20px;
    }

    .controls {
        width: 100%;
        order: 1;
        /* 控制区域在上 */
    }

    .preview-wrapper {
        width: 100%;
        order: 2;
        /* 预览区域在下 */
        margin-top: 20px;
    }

    .preview-container {
        width: 100%;
        max-width: 365px;
        height: auto;
        aspect-ratio: 3/4;
        /* 保持3:4的比例 */
    }

    #preview {
        width: 100%;
        height: 100%;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .input-group {
        gap: 6px;
    }

    label {
        font-size: 14px;
    }

    input[type="text"],
    select,
    button {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* 更小屏幕的额外调整 */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .editor {
        padding: 15px;
        gap: 15px;
        border-radius: 8px;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 15px;
    }

    .preview-container {
        border-width: 3px;
    }

    button {
        padding: 10px 16px;
    }
}