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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #a8e6cf 0%, #88d8b0 100%);
    min-height: 100vh;
    padding: 20px;
}

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

h1 {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    font-size: 2rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* 预览区域 */
.preview-area {
    display: flex;
    flex-direction: column;
}

.preview-box {
    flex: 1;
    background: #f8f9fa;
    border: 3px dashed #dee2e6;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.preview-box.drag-over {
    border-color: #74b9ff;
    background: #f0f8ff;
}

.preview-box canvas {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    cursor: default;
}

.placeholder {
    text-align: center;
    color: #adb5bd;
}

.placeholder svg {
    margin-bottom: 15px;
    opacity: 0.5;
}

.placeholder p {
    font-size: 1rem;
}

/* 图片列表容器 */
.image-list-container {
    margin-top: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
}

.image-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 5px;
    font-size: 0.9rem;
    color: #495057;
}

.image-list-header strong {
    color: #74b9ff;
    font-size: 1rem;
}

.btn-clear {
    padding: 5px 15px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-clear:hover {
    background: #c82333;
    transform: scale(1.05);
}

.image-list {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

.image-list::-webkit-scrollbar {
    width: 8px;
}

.image-list::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 4px;
}

.image-list::-webkit-scrollbar-thumb {
    background: #74b9ff;
    border-radius: 4px;
}

.image-list::-webkit-scrollbar-thumb:hover {
    background: #5a9fd4;
}

.image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.image-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.image-item.selected {
    border: 3px solid #74b9ff;
    box-shadow: 0 0 0 3px rgba(116, 185, 255, 0.3);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 8px;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-item-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all 0.3s ease;
}

.image-item-remove:hover {
    background: #dc3545;
    transform: scale(1.1);
}

/* 控制面板 */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

/* 水印区块 */
.watermark-section {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 12px;
}

.watermark-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
}

.watermark-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.inline-text-input {
    flex: 1;
    min-width: 120px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.75rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.inline-text-input:focus {
    border-color: #74b9ff;
}

.watermark-spacer {
    flex: 1;
}

.watermark-count {
    font-size: 0.75rem;
    color: #6c757d;
    white-space: nowrap;
}

.watermark-count strong {
    color: #74b9ff;
}

.btn-add-watermark {
    flex: 0 0 auto;
    height: 28px;
    padding: 0 12px;
    background: linear-gradient(135deg, #74b9ff 0%, #a0d2ff 100%);
    color: white;
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.btn-add-watermark svg {
    width: 12px;
    height: 12px;
}

.btn-add-watermark:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(116, 185, 255, 0.4);
}

.watermark-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px;
    min-height: 28px;
}

.watermark-list::-webkit-scrollbar {
    height: 6px;
}

.watermark-list::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 3px;
}

.watermark-list::-webkit-scrollbar-thumb {
    background: #74b9ff;
    border-radius: 3px;
}

.watermark-item {
    flex-shrink: 0;
    width: 60px;
    height: 30px;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    background: white;
    border: 2px solid #e9ecef;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 500;
    padding: 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.watermark-item canvas,
.watermark-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.watermark-item:hover {
    border-color: #74b9ff;
    transform: scale(1.05);
}

.watermark-item.selected {
    border-color: #74b9ff;
    box-shadow: 0 0 0 3px rgba(116, 185, 255, 0.3);
    background: #f0f8ff;
}

.watermark-item canvas,
.watermark-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.watermark-item .watermark-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    font-size: 0.55rem;
    text-align: center;
    word-break: break-all;
}

.watermark-item-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    transition: all 0.3s ease;
}

.watermark-item:hover .watermark-item-remove {
    display: flex;
}

.watermark-item-remove:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.upload-section,
.download-section {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.download-buttons {
    display: flex;
    gap: 10px;
}

.download-buttons .btn {
    flex: 1;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group.half {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.control-group.third {
    flex: 1.5;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.control-group.two-thirds {
    flex: 1.5;
    display: grid;
    grid-template-rows: 0.75fr 1.5fr 0.75fr;
}

.control-group.two-thirds > .control-group:first-child {
    grid-row: 1;
    align-self: center;
}

.control-group.two-thirds > .control-group:last-child {
    grid-row: 3;
    align-self: center;
}

.control-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.6rem;
    font-weight: 500;
    color: #495057;
}

.label-text {
    flex: 1;
}

.value-display {
    color: #74b9ff;
    font-weight: 600;
    min-width: 33px;
    text-align: right;
    font-size: 0.6rem;
}

/* 滑块样式 */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    background: #e9ecef;
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    background: linear-gradient(135deg, #74b9ff 0%, #a0d2ff 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(116, 185, 255, 0.4);
    transition: transform 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 13px;
    height: 13px;
    background: linear-gradient(135deg, #74b9ff 0%, #a0d2ff 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(116, 185, 255, 0.4);
}

/* 输入框样式 */
.text-input,
.number-input,
.select-input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #e9ecef;
    border-radius: 7px;
    font-size: 0.63rem;
    transition: all 0.3s ease;
    background: white;
}

.text-input:focus,
.number-input:focus,
.select-input:focus {
    outline: none;
    border-color: #74b9ff;
    box-shadow: 0 0 0 3px rgba(116, 185, 255, 0.1);
}

/* 字体选择器 */
.font-select {
    width: 100%;
    padding: 6px 8px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.7rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.font-select:focus {
    outline: none;
    border-color: #74b9ff;
    box-shadow: 0 0 0 3px rgba(116, 185, 255, 0.1);
}

/* 单选按钮组样式 */
.radio-group {
    display: flex;
    gap: 7px;
}

.radio-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.radio-option:hover {
    border-color: #74b9ff;
    background: #f0f8ff;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-option input[type="radio"]:checked + span {
    color: #74b9ff;
    font-weight: 600;
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: #74b9ff;
    background: #f0f8ff;
}

.radio-option span {
    font-size: 0.63rem;
    color: #495057;
}

/* 九宫格位置选择器 */
.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.position-btn {
    padding: 8px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #6c757d;
}

.position-btn:hover {
    border-color: #74b9ff;
    background: #f0f8ff;
    color: #74b9ff;
}

.position-btn.active {
    border-color: #74b9ff;
    background: linear-gradient(135deg, #74b9ff 0%, #a0d2ff 100%);
    color: white;
}

/* 九宫格位置选择器（紧凑版） */
.position-grid-compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.position-grid-compact .position-btn {
    padding: 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}

.text-label {
    margin-bottom: 3px;
    font-size: 0.6rem;
    font-weight: 500;
    color: #495057;
}

/* 颜色选择器 */
.color-input {
    width: 100%;
    height: 30px;
    padding: 3px;
    border: 2px solid #e9ecef;
    border-radius: 7px;
    cursor: pointer;
    background: white;
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* 数字输入后缀 */
.input-suffix {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: 0.85rem;
    pointer-events: none;
}

.control-group.half {
    position: relative;
}

/* 按钮样式 */
.btn {
    width: 100%;
    padding: 9px 13px;
    border: none;
    border-radius: 7px;
    font-size: 0.67rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #74b9ff 0%, #a0d2ff 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #74b9ff 0%, #a0d2ff 100%);
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(116, 185, 255, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e9ecef;
    color: #adb5bd;
}

/* 响应式设计 */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .preview-box {
        min-height: 300px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .main-content {
        padding: 20px;
        gap: 20px;
    }

    .control-row {
        flex-direction: column;
        gap: 20px;
    }
}

/* 可折叠区域样式 */
.collapsible-section {
    margin-bottom: 5px;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.collapsible-header:hover {
    background: #f5f5f5;
    margin: 0 -10px;
    padding: 8px 10px;
    border-radius: 5px;
}

.collapse-icon {
    font-size: 12px;
    color: #666;
    transition: transform 0.2s ease;
}

.collapse-icon.expanded {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
}

.collapsible-content.collapsed .position-grid {
    display: none;
}
