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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #1f2937;
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    text-align: center;
    margin-bottom: 10px;
}

.canvas-container {
    position: relative;
    border: 3px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f9fafb;
    cursor: pointer;
    transition: border-color 0.2s ease;
    /* 容器大小自适应canvas显示尺寸 */
    display: inline-block;
    width: fit-content;
    height: fit-content;
    max-width: 50vw;
    max-height: 50vh;
}

.canvas-container:hover {
    border-color: #2563eb;
}

.canvas-container.drag-over {
    border: 3px dashed #2563eb;
    background-color: #eff6ff;
}

#imageCanvas {
    display: block;
    /* 移除max-width和max-height限制，让容器来控制大小 */
    width: auto;
    height: auto;
    /* 确保canvas不会超出视口的50% */
    max-width: calc(50vw - 6px); /* 减去border宽度 */
    max-height: calc(50vh - 6px); /* 减去border宽度 */
}

.file-operations {
    display: flex;
    align-items: center;
    gap: 15px;
}

.filename-input {
    width: 200px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.filename-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.btn-primary {
    background-color: #2563eb;
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #64748b;
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .file-operations {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .filename-input {
        width: 100%;
    }
    
    #imageCanvas {
        max-width: 100%;
        height: auto;
    }
}

/* 拖拽提示 */
.drag-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #2563eb;
    font-size: 16px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.canvas-container.drag-over .drag-hint {
    opacity: 1;
}