:root {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 40px 20px;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
}

.container {
    display: flex;
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
    align-items: flex-start;
}

@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
}

/* 左侧编辑器 */
.editor {
    flex: 1;
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    min-width: 400px;
}

.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

input[type="text"], 
input[type="number"], 
select, 
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #fff;
    font-size: 1rem;
    transition: all 0.2s ease;
    color: var(--text-main);
}

input[type="text"]:focus, 
input[type="number"]:focus, 
select:focus, 
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

input[type="file"] {
    display: block;
    width: 100%;
    padding: 10px;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
}

/* 评分 */
.star-rating span {
    cursor: pointer;
    font-size: 28px;
    color: #cbd5e1;
    transition: color 0.2s;
    margin-right: 4px;
}

.star-rating span.active {
    color: #fbbf24;
}

/* 分类选择器 */
.category-selector {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.main-categories {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.main-categories button {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.main-categories button:hover {
    background-color: #f1f5f9;
}

.main-categories button.active {
    /* JS 会设置背景色，这里只设置字体和阴影增强效果 */
    color: white !important;
    border-color: transparent;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-weight: 600;
}

.sub-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 16px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
}

/* 食材选择器样式 */
.ingredient-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ingredient-selector button {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ingredient-selector button.active {
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.quantity-select {
    width: 80px;
    padding: 6px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

/* 步骤编辑 */
.step {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.step:focus-within {
    border-color: var(--primary-color);
}

.step textarea {
    height: 80px;
    resize: vertical;
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
}

.step-image-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    padding: 10px;
    border-radius: var(--radius-sm);
}

.step-image-label {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.step-image-label:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.step-image-input {
    display: none;
}

.step-image-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.delete-image-btn {
    background-color: #fee2e2;
    color: #ef4444;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

.delete-image-btn:hover {
    background-color: #fecaca;
}

#addStep {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    transition: background 0.2s;
}

#addStep:hover {
    background: var(--primary-dark);
}

/* 右侧预览区 */
.preview {
    flex: 1;
    position: sticky;
    top: 40px;
}

/* 预览卡片核心样式 - 现代简洁风 */
.recipe-card {
    background-color: white;
    /* 去除虚线边框，使用柔和阴影 */
    border: none;
    box-shadow: var(--shadow-lg); 
    border-radius: var(--radius-lg);
    padding: 40px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    position: relative;
    overflow: hidden;
    min-height: auto;
}

/* 背景图遮罩 */
#previewContent {
    position: relative;
    width: 100%;
}

#previewContent::before {
    /* 背景图更加淡化 */
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--bg-image, none);
    background-size: cover;
    background-position: center;
    opacity: 0.05;
    z-index: 0;
    pointer-events: none;
}

/* 菜名标题区 */
.dish-title {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    z-index: 2;
}

.title-circles {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
}

/* 重置圆形标题样式为现代排版 */
.circle {
    display: inline-block;
    width: auto;
    height: auto;
    background-color: transparent !important; /* 强制覆盖 JS 可能的样式 */
    color: var(--text-main);
    font-size: 2.5rem;
    font-weight: 800;
    border-radius: 0;
    margin: 0;
    border: none !important;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* 信息区 */
.info-section {
    display: flex;
    /* 去除背景色，改为透明或极淡 */
    background-color: transparent;
    border-radius: 0;
    margin-bottom: 40px;
    gap: 30px;
    align-items: flex-start;
    position: relative;
    z-index: 2;
}

.dish-image {
    width: 200px;
    height: 200px;
    padding: 0;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.dish-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

.dish-info {
    width: auto;
    flex: 1;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
}

.info-item {
    margin: 0;
    display: flex;
    align-items: center;
    line-height: 1.5;
}

.info-label {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: #8a8a8a;
    font-weight: 400;
    margin-right: 12px;
    min-width: 70px;
}

.info-item > span:not(.info-label) {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    color: #333333;
    font-weight: 500;
}

.info-item .star-display {
    color: #fbbf24;
    font-size: 18px; /* Slightly larger stars */
    letter-spacing: 2px;
    text-shadow: none;
}

#previewKcal {
    color: #ff6b6b;
    font-weight: 600;
}

/* 章节通用样式 */
.ingredients-section, .steps-section {
    margin-bottom: 40px;
    position: relative;
    z-index: 2;
}

.ingredients-title, .steps-title {
    margin-bottom: 24px;
    text-align: left; /* 左对齐更现代 */
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 12px;
}

/* 重置标题背景块样式 */
.section-title-bg {
    display: inline-block;
    background-color: transparent !important;
    color: var(--text-main);
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0;
    box-shadow: none;
    position: relative;
}

/* 食材内容 */
.ingredients-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
    padding: 0;
}

.ingredient-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: #f8fafc;
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    width: auto;
    margin: 0;
    border: 1px solid #f1f5f9;
}

.ingredient-name {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 4px;
}

.ingredient-quantity {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* 步骤内容 */
.steps-content {
    padding: 0;
}

.step-item {
    display: flex;
    margin-bottom: 24px;
    align-items: flex-start;
    position: relative;
    gap: 16px; /* 统一间距 */
}

.step-number {
    font-weight: 700;
    margin-right: 0; /* 使用gap代替margin-right */
    font-size: 1.5rem;
    color: var(--primary-color);
    line-height: 1;
    opacity: 0.8;
    flex-shrink: 0; /* 防止数字被挤压 */
}

.step-text {
    flex: 1; /* 占据剩余空间 */
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.6;
    margin-top: 4px; /* 与数字顶部对齐 */
    min-width: 0; /* 防止长文本撑开布局 */
    word-wrap: break-word; /* 长单词换行 */
}

/* 步骤图片容器，仅在有图片时显示 */
.step-image {
    margin-top: 0;
    width: 120px;
    height: 90px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-left: 16px; /* 强制左侧间距 */
    box-shadow: var(--shadow-sm);
}

.preview-step-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Logo */
.recipe-logo {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #f1f5f9;
    opacity: 0.5;
}

.recipe-logo img {
    max-height: 50px;
    opacity: 0.9;
    object-fit: contain;
}

/* 下载按钮 */
.download-container {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
}

.download-btn {
    background-color: var(--text-main);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.download-btn:hover {
    background-color: #000;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.download-btn:active {
    transform: translateY(0);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .recipe-card {
        padding: 24px;
    }
    
    .info-section {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .dish-info {
        width: 100%;
        align-items: center;
    }
    
    .dish-title .circle {
        font-size: 1.8rem;
    }
}
