@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Fredoka+One&display=swap');

:root {
    --bg-cream: #FDF6E3;
    --bg-warm: #F5EBD9;
    --accent-coral: #FF6B6B;
    --accent-teal: #4ECDC4;
    --accent-yellow: #FFE66D;
    --accent-purple: #A06CD5;
    --accent-blue: #45B7D1;
    --text-dark: #2D3436;
    --text-soft: #636E72;
    --shadow-soft: rgba(45, 52, 54, 0.08);
    --shadow-medium: rgba(45, 52, 54, 0.15);
    --grid-line: rgba(45, 52, 54, 0.1);
}

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

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg-cream);
    min-height: 100vh;
    color: var(--text-dark);
    position: relative;
    overflow-x: hidden;
}

/* 背景网格纹理 - 模拟拼豆板 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at center, var(--grid-line) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 0;
}

/* 装饰性拼豆 */
body::after {
    content: '';
    position: fixed;
    top: -50px;
    right: -50px;
    width: 300px;
    height: 300px;
    background:
        radial-gradient(circle at 30% 30%, var(--accent-coral) 8px, transparent 8px),
        radial-gradient(circle at 50% 50%, var(--accent-teal) 8px, transparent 8px),
        radial-gradient(circle at 70% 40%, var(--accent-yellow) 8px, transparent 8px),
        radial-gradient(circle at 40% 70%, var(--accent-purple) 8px, transparent 8px),
        radial-gradient(circle at 60% 80%, var(--accent-blue) 8px, transparent 8px);
    opacity: 0.6;
    pointer-events: none;
    z-index: 0;
    animation: floatBeads 8s ease-in-out infinite;
}

@keyframes floatBeads {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(-10px, 10px) rotate(5deg); }
}

.page {
    display: none;
    min-height: 100vh;
    padding: 30px 20px;
    position: relative;
    z-index: 1;
}

.page.active {
    display: block;
    animation: pageIn 0.5s ease-out;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border-radius: 24px;
    padding: 40px;
    box-shadow:
        0 4px 6px var(--shadow-soft),
        0 20px 50px var(--shadow-medium);
    position: relative;
    border: 3px solid var(--bg-warm);
}

/* 容器角落装饰 */
.container::before,
.container::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    opacity: 0.8;
}

.container::before {
    top: -12px;
    left: -12px;
    background: var(--accent-coral);
    box-shadow: 60px 0 0 var(--accent-teal), 120px 0 0 var(--accent-yellow);
}

.container::after {
    bottom: -12px;
    right: -12px;
    background: var(--accent-purple);
    box-shadow: -60px 0 0 var(--accent-blue), -120px 0 0 var(--accent-coral);
}

h1 {
    text-align: center;
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--accent-coral) 0%, var(--accent-purple) 50%, var(--accent-teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    position: relative;
}

h1::after {
    content: '✨';
    position: absolute;
    right: -30px;
    top: 0;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(15deg); }
}

.subtitle {
    text-align: center;
    color: var(--text-soft);
    font-size: 1rem;
    margin-bottom: 35px;
    font-weight: 600;
}

h2, h3 {
    font-family: 'Fredoka One', cursive;
    color: var(--text-dark);
    margin-bottom: 20px;
    font-weight: 400;
}

h2 {
    font-size: 1.8rem;
    text-align: center;
}

h3 {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

h3::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-coral);
}

/* 上传区域 */
.upload-section {
    margin-bottom: 35px;
}

.upload-area {
    border: 3px dashed var(--accent-teal);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(78, 205, 196, 0.05) 0%, rgba(255, 230, 109, 0.05) 100%);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at center, rgba(78, 205, 196, 0.1) 2px, transparent 2px);
    background-size: 16px 16px;
    opacity: 0.5;
    pointer-events: none;
}

.upload-area:hover {
    border-color: var(--accent-coral);
    transform: scale(1.02);
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.2);
}

.upload-area.dragover {
    border-color: var(--accent-purple);
    background: rgba(160, 108, 213, 0.1);
    transform: scale(1.03);
}

.upload-area.has-image {
    border-style: solid;
    padding: 15px;
    background: #fff;
}

.upload-placeholder {
    color: var(--accent-teal);
    position: relative;
    z-index: 1;
}

.upload-icon {
    font-size: 60px;
    margin-bottom: 15px;
    display: block;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.upload-placeholder p {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-soft);
}

.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    box-shadow: 0 8px 25px var(--shadow-medium);
}

/* 参数区域 */
.params-section {
    margin-bottom: 35px;
    background: var(--bg-warm);
    padding: 25px;
    border-radius: 16px;
}

.param-group {
    margin-bottom: 25px;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-soft);
    transition: transform 0.3s ease;
}

.param-group:hover {
    transform: translateX(5px);
}

.param-group:last-child {
    margin-bottom: 0;
}

.param-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--text-dark);
    font-size: 1rem;
}

.param-group label::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-coral);
}

.param-group:nth-child(2) label::before {
    background: var(--accent-teal);
}

.param-group:nth-child(3) label::before {
    background: var(--accent-yellow);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--accent-coral);
    color: #fff;
    border-radius: 10px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(255, 107, 107, 0.3);
}

.slider-btn:hover {
    transform: scale(1.15);
    background: var(--accent-purple);
}

.slider-btn:active {
    transform: scale(0.95);
}

input[type="range"] {
    flex: 1;
    height: 10px;
    -webkit-appearance: none;
    background: linear-gradient(90deg, var(--accent-teal), var(--accent-purple));
    border-radius: 10px;
    outline: none;
    opacity: 0.8;
    transition: opacity 0.3s;
}

input[type="range"]:hover {
    opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px var(--shadow-medium);
    border: 3px solid var(--accent-coral);
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.value-display {
    min-width: 60px;
    text-align: center;
    font-weight: 800;
    color: var(--accent-purple);
    background: rgba(160, 108, 213, 0.1);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.95rem;
}

.param-hint {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-soft);
    padding-left: 18px;
    border-left: 3px solid var(--accent-yellow);
}

/* 按钮 */
.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    margin: 25px auto;
    padding: 18px 35px;
    background: linear-gradient(135deg, var(--accent-coral) 0%, var(--accent-purple) 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
    position: relative;
    overflow: hidden;
}

.primary-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.primary-btn:hover:not(:disabled)::before {
    left: 100%;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 40px rgba(255, 107, 107, 0.5);
}

.primary-btn:active:not(:disabled) {
    transform: translateY(-2px) scale(0.98);
}

.primary-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.secondary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    margin: 20px auto;
    padding: 16px 30px;
    background: #fff;
    color: var(--accent-teal);
    border: 3px solid var(--accent-teal);
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.secondary-btn:hover {
    background: var(--accent-teal);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(78, 205, 196, 0.4);
}

/* 预览页 */
.comparison-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 35px;
}

.compare-item {
    text-align: center;
}

.compare-item h3::before {
    background: var(--accent-teal);
}

.compare-item:last-child h3::before {
    background: var(--accent-purple);
}

.image-frame {
    border: 3px solid var(--bg-warm);
    border-radius: 16px;
    padding: 15px;
    background: #fff;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 0 2px 10px var(--shadow-soft),
        0 4px 15px var(--shadow-soft);
    position: relative;
}

.image-frame::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 2px dashed var(--grid-line);
    border-radius: 10px;
    pointer-events: none;
}

.image-frame img,
.image-frame canvas {
    max-width: 100%;
    max-height: 350px;
    border-radius: 8px;
}

/* 模板页 */
.template-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 22px;
    max-width: 1200px;
    padding-bottom: 100px;
}

.template-section {
    min-width: 0;
}

.color-table-section {
    min-width: 0;
}

.template-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 12px 14px;
    background: var(--bg-warm);
    border-radius: 14px;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tool-btn {
    border: 2px solid var(--accent-teal);
    background: #fff;
    color: var(--text-dark);
    font-weight: 700;
    border-radius: 12px;
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: var(--accent-teal);
    color: #fff;
}

.tool-btn.active {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    color: #fff;
}

.tool-btn.tool-muted {
    border-color: var(--bg-warm);
    color: var(--text-soft);
}

.active-color {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 2px solid var(--bg-warm);
    background: #fff;
    display: inline-block;
    box-shadow: 0 2px 8px var(--shadow-soft);
}

.active-color-label {
    font-weight: 700;
    color: var(--accent-purple);
}

.tool-hint {
    font-size: 0.8rem;
    color: var(--text-soft);
}

.template-frame {
    border: 3px solid var(--accent-teal);
    border-radius: 16px;
    overflow: hidden;
    cursor: grab;
    position: relative;
    height: 680px;
    background:
        linear-gradient(45deg, #f8f8f8 25%, transparent 25%),
        linear-gradient(-45deg, #f8f8f8 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f8f8f8 75%),
        linear-gradient(-45deg, transparent 75%, #f8f8f8 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #fff;
    box-shadow: inset 0 4px 20px var(--shadow-soft);
}

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

#templateCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 10px 40px var(--shadow-medium);
    border-radius: 4px;
}

#templateOverlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.zoom-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-soft);
    margin-top: 12px;
    padding: 8px 15px;
    background: var(--bg-warm);
    border-radius: 20px;
    display: inline-block;
    width: 100%;
}

.template-info {
    margin-top: 18px;
    padding: 18px;
    background: linear-gradient(135deg, var(--bg-warm) 0%, #fff 100%);
    border-radius: 12px;
    font-size: 0.95rem;
    border-left: 4px solid var(--accent-coral);
    box-shadow: 0 2px 10px var(--shadow-soft);
}

.template-info strong {
    color: var(--accent-purple);
}

.color-table-frame {
    border: 3px solid var(--bg-warm);
    border-radius: 16px;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    box-shadow: 0 4px 20px var(--shadow-soft);
}

.color-table-frame::-webkit-scrollbar {
    width: 8px;
}

.color-table-frame::-webkit-scrollbar-track {
    background: var(--bg-warm);
    border-radius: 4px;
}

.color-table-frame::-webkit-scrollbar-thumb {
    background: var(--accent-teal);
    border-radius: 4px;
}

#colorTable {
    width: 100%;
    border-collapse: collapse;
}

#colorTable th,
#colorTable td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid var(--bg-warm);
}

#colorTable th {
    background: linear-gradient(135deg, var(--accent-coral) 0%, var(--accent-purple) 100%);
    color: #fff;
    position: sticky;
    top: 0;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

#colorTable tbody tr {
    transition: background 0.3s;
}

#colorTable tbody tr:hover {
    background: rgba(78, 205, 196, 0.1);
}

#colorTable td:first-child {
    width: 50px;
}

#colorTable td:nth-child(2) {
    font-weight: 700;
    color: var(--accent-purple);
}

#colorTable td:last-child {
    font-weight: 700;
    color: var(--accent-coral);
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-block;
    border: 2px solid var(--bg-warm);
    box-shadow: 0 2px 8px var(--shadow-soft);
    transition: transform 0.3s;
}

#colorTable tbody tr:hover .color-swatch {
    transform: scale(1.15);
}

#colorTable tbody tr {
    cursor: pointer;
}

#colorTable tbody tr.color-active {
    background: rgba(160, 108, 213, 0.15);
    box-shadow: inset 3px 0 0 var(--accent-purple);
}

#colorTable tbody tr.color-active td:nth-child(2) {
    color: var(--accent-coral);
}

#colorTable tbody tr.color-active .color-swatch {
    transform: scale(1.15);
    border-color: var(--accent-purple);
}

/* 底部按钮 */
.bottom-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 2px solid var(--bg-warm);
    box-shadow: 0 -5px 30px var(--shadow-soft);
    z-index: 100;
}

.bottom-buttons .primary-btn,
.bottom-buttons .secondary-btn {
    margin: 0;
    width: auto;
    min-width: 180px;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 52, 54, 0.95);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalIn 0.3s ease-out;
}

/* 裁剪弹窗 */
.crop-modal-panel {
    width: min(92vw, 980px);
    max-height: 92vh;
    background: #fff;
    border-radius: 20px;
    padding: 18px 20px 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.crop-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crop-modal-header h3 {
    margin: 0;
}

.crop-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--accent-coral);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}

.crop-close-btn:hover {
    background: var(--accent-purple);
    transform: rotate(90deg);
}

.crop-modal-body {
    flex: 1;
    overflow: auto;
    padding: 8px;
    background: var(--bg-warm);
    border-radius: 16px;
}

.crop-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 0 auto;
}

#cropImage {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px;
    box-shadow: 0 8px 25px var(--shadow-medium);
}

.crop-box {
    position: absolute;
    border: 2px solid var(--accent-coral);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    border-radius: 6px;
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent-coral);
}

.crop-handle.nw { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-handle.ne { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.crop-handle.se { bottom: -7px; right: -7px; cursor: nwse-resize; }

.crop-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.crop-modal-actions .primary-btn,
.crop-modal-actions .secondary-btn {
    margin: 0;
    width: auto;
    min-width: 140px;
    padding: 12px 22px;
    font-size: 1rem;
}

/* 色卡选择面板 */
.color-picker-panel {
    width: min(92vw, 980px);
    max-height: 92vh;
    background: #fff;
    border-radius: 20px;
    padding: 18px 20px 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.color-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 10px;
    overflow: auto;
    padding: 6px;
    background: var(--bg-warm);
    border-radius: 14px;
    max-height: 70vh;
}

.color-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #fff;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-picker-item:hover {
    transform: translateY(-2px);
    border-color: var(--accent-teal);
}

.color-picker-swatch {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1px solid var(--bg-warm);
}

.color-picker-code {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark);
}

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

.modal-content {
    position: relative;
    width: 95%;
    height: 95%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 45px;
    color: #fff;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.3s;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-coral);
    border-radius: 50%;
    line-height: 1;
}

.close-btn:hover {
    background: var(--accent-purple);
    transform: rotate(90deg);
}

.modal-canvas-container {
    overflow: auto;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#modalCanvas {
    max-width: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
}

/* 加载动画 */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* 响应式 */
@media (max-width: 900px) {
    .color-table-frame {
        max-height: 220px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 25px 20px;
        border-radius: 20px;
        margin: 10px;
    }

    .container::before,
    .container::after {
        display: none;
    }

    h1 {
        font-size: 1.8rem;
    }

    h1::after {
        display: none;
    }

    .comparison-section {
        grid-template-columns: 1fr;
    }

    .bottom-buttons {
        flex-direction: column;
        align-items: center;
        padding: 15px;
    }

    .bottom-buttons .primary-btn,
    .bottom-buttons .secondary-btn {
        width: 100%;
        max-width: 280px;
    }

    .param-group {
        padding: 15px;
    }

    .slider-container {
        flex-wrap: wrap;
    }

    input[type="range"] {
        order: 3;
        width: 100%;
        flex: none;
        margin-top: 10px;
    }
}

/* 打印样式优化 */
@media print {
    body::before,
    body::after {
        display: none;
    }

    .bottom-buttons {
        display: none;
    }
}

/* 图片来源切换标签 */
.source-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 25px;
    background: var(--bg-warm);
    border-radius: 50px;
    padding: 5px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.source-tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-soft);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s ease;
}

.source-tab:hover {
    color: var(--text-dark);
}

.source-tab.active {
    background: linear-gradient(135deg, var(--accent-coral) 0%, var(--accent-purple) 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

/* AI 生成区域 */
.ai-section {
    margin-bottom: 35px;
}

.ai-prompt-container {
    background: linear-gradient(135deg, rgba(160, 108, 213, 0.05) 0%, rgba(78, 205, 196, 0.05) 100%);
    border: 2px solid var(--bg-warm);
    border-radius: 20px;
    padding: 25px;
}

.ai-prompt-container label {
    display: block;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-dark);
    font-size: 1.1rem;
}

.ai-prompt-input {
    width: 100%;
    min-height: 120px;
    padding: 18px;
    border: 2px solid var(--bg-warm);
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    color: var(--text-dark);
    background: #fff;
    resize: vertical;
    transition: all 0.3s ease;
    line-height: 1.6;
}

.ai-prompt-input:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 4px rgba(160, 108, 213, 0.15);
}

.ai-prompt-input::placeholder {
    color: var(--text-soft);
    opacity: 0.7;
}

.ai-prompt-tips {
    margin-top: 12px;
    padding: 10px 15px;
    background: rgba(255, 230, 109, 0.3);
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text-soft);
}

.ai-prompt-tips span::before {
    content: '💡';
    margin-right: 6px;
}

.ai-generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 20px;
    padding: 18px 35px;
    background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 25px rgba(160, 108, 213, 0.4);
    position: relative;
    overflow: hidden;
}

.ai-generate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.ai-generate-btn:hover::before {
    left: 100%;
}

.ai-generate-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 40px rgba(160, 108, 213, 0.5);
}

.ai-generate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.ai-generate-btn .btn-icon {
    font-size: 1.4rem;
}

/* AI 预览区域 */
.ai-preview {
    margin-top: 25px;
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    border: 2px solid var(--accent-teal);
    box-shadow: 0 8px 30px var(--shadow-soft);
}

.ai-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.ai-preview-header span {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 1rem;
}

.ai-regenerate-btn {
    padding: 8px 18px;
    background: transparent;
    color: var(--accent-purple);
    border: 2px solid var(--accent-purple);
    border-radius: 20px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ai-regenerate-btn:hover {
    background: var(--accent-purple);
    color: #fff;
}

.ai-preview .preview-image {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 12px;
}

/* AI 加载动画 */
.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, rgba(160, 108, 213, 0.05) 0%, rgba(78, 205, 196, 0.05) 100%);
    border-radius: 20px;
    margin-top: 20px;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(
        var(--accent-coral),
        var(--accent-purple),
        var(--accent-teal),
        var(--accent-yellow),
        var(--accent-coral)
    );
    animation: spin 1.5s linear infinite;
    position: relative;
}

.loading-spinner::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    background: #fff;
    border-radius: 50%;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ai-loading p {
    margin-top: 20px;
    font-weight: 700;
    color: var(--text-soft);
    font-size: 1rem;
    animation: pulse 1.5s ease-in-out infinite;
}

